Code Monkey home page Code Monkey logo

documentbuilder's Introduction

Overview

ONLYOFFICE Document Builder allows you to build docs easily without running an actual editor. It also allows the developers to automate document building using the templates.

Document Builder has all the features of a common document editor but is lightweight and can be easily integrated into your document management system, CRM system, etc.

Project information

Official website: https://www.onlyoffice.com/document-builder.aspx

Code repository: https://github.com/ONLYOFFICE/DocumentBuilder

Document Builder API https://api.onlyoffice.com/docbuilder/basic

ONLYOFFICE Document Builder is dual-licensed. For commercial use, contact [email protected]

documentbuilder's People

Contributors

agolybev avatar askonev avatar denisdeesign avatar flaminestone avatar github-actions[bot] avatar heatray avatar hellonadya avatar papacarlo avatar romandemidov avatar sergeyluzyanin avatar shockwavenn avatar trofim24 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

documentbuilder's Issues

x32 centos/debian cause window.Asc.asc_docs_api is not a constructor

  1. Install latest centos x32 docbuilder
documentbuilder -v
v4.4.1.38
  1. Create test.js
builder.CreateFile("xlsx");
var oWorksheet = Api.GetActiveSheet();
oWorksheet.SetName("sheet 1");
oWorksheet.GetRange("A1").SetValue("Value");
builder.SaveFile("xlsx", "AddTextToSell.xlsx");
builder.CloseFile();
  1. documentbuilder test.js

This cause

open_code:              _api = new window["Asc"]["spreadsheet_api"]({});
open: Uncaught TypeError: window.Asc.spreadsheet_api is not a constructor

x64 documentbuilder in docker centos env working file

Tested on:
Centos 7 x32

linux - activation create lickey in current dir, instead of installation dir

1.Install onlyoffice-documentbuilder 4.4.1-47
2. cd /tmp
2. Run /opt/onlyoffice/documentbuilder/registration
3. Enter registration key with success activation

Result:
Key created in current folder (/tmp/license/key.lickey) dir, but should in installation dir - /opt/onlyoffice/documentbuilder/ and docbuilder raise warning: : license error
ubuntu 16.04

Uncaught TypeError: Api.AddComment is not a function 6.2.0-123-linux

I got 'Uncaught TypeError: Api.AddComment is not a function' message.

var oDocument = Api.GetDocument();
var oParagraph, oRun, result;

oParagraph = oDocument.GetElement(0);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Dear John Smith.");

oRun = oParagraph.AddText("This text was added by ONLYOFFICE Document Builder ");
result = Api.AddComment(oRun, "Hello, can u see me!", "Unknown Reviewer");

builder.SaveFile("docx", "./TEST_FILES/sample_comments.docx");
builder.CloseFile();

I am using a up-to-date version of document_buIlder 6.2.0-123 on linux mint 20

So my question is "How to correctly add a comment to ApiRun",
https://api.onlyoffice.com/docbuilder/textdocumentapi/api/addcomment have no examples on using it with ApiRun.

documentbuilder run fail

documentbuilder add_content_control.docbuilder

add_content_control.docbuilder:

builder.OpenFile("./src_sdt.docx")
var oDocument = Api.GetDocument();
var oRange = oDocument.GetRange(0);

var arrParagraphs = oRange.GetAllParagraphs();
console.log(arrParagraphs.length)

try {
    var arrParagraphs = oRange.GetAllParagraphs();
    console.log(arrParagraphs.length)
    for (var i = 0; i < arrParagraphs.length; i++) {
        var oParagraph = arrParagraphs[i];
        if (oParagraph.GetClassType() == "paragraph") {
            // add ContentControl
           // if (i >=0 && i<=20000) // fine
            // if (i >=20000 && i<=32000) // fine
            // if (i >=20000 && i<=30000) // fine
            // if (i >=21000 && i<=32000) // fine
            // if (i >=10000 && i<=32000) // fine
            // if (i >=0 && i<=32000) // error
            // if (i >=0 && i<=30000)  // error
            // if (i >=0 && i<=28000)  // error
            if (i >=0 && i<=25000)  //error
            {
                oBlockLvlSdt = oParagraph.InsertInContentControl(1);
                oBlockLvlSdt.SetLock(3);
                oBlockLvlSdt.SetTag(Math.random().toString(36).substring(7));
            }
        }
    }
}
catch (error) {
    console.log("error", error);
}

builder.SaveFile("docx", "dst_add_sdt.docx");
builder.CloseFile();

arrParagraphs.length=31928

I guess it's because there are run too many function InsertInContentControl.

error info:

<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x76627d28969 <JSObject>
    1: new cf [0x19ae0a882311 <undefined>:~11792] [pc=0x17099f553125](this=0x3563f1d2ec31 <cf map = 0x62b5010bc01>,b=0xfdea55e5f29 <JSObject>,e=0x19cfc0c88779 <fh map = 0x62b5015bf39>,x=0x19ae0a882421 <false>)
    3: /* anonymous */ [0x19ae0a882311 <undefined>:~20688] [pc=0x17099f619f3b](this=0x19cfc0c88779 <fh map = 0x62b5015bf39>,b=0,e=1,x=0x19ae0a882311 <undefined>)
    4: /* anonymous */ [0x1...


#
# Fatal javascript OOM in CALL_AND_RETRY_LAST
#

Received signal 4 ILL_ILLOPN 7f6d8ef8a4e9

==== C stack trace ===============================

 [0x7f6d8ef8b732]
 [0x7f6d8e423210]
 [0x7f6d8ef8a4e9]
 [0x7f6d8e7a5f7d]
 [0x7f6d8e7a617c]
 [0x7f6d8e97365f]
 [0x7f6d8eee977c]
 [0x17099f3046fd]
[end of stack trace]
Illegal instruction

builder.OpenFile and other builder.xxxx operations fail silently when single quotes are used in arguments

Was using documentbuilder v7.5 from the cli using docbuilder.

Had a .docbuilder file whose first line was

builder.OpenFile('myfile.xlsx')

Next line was Api.GetSheet... got an error message saying Api not defined.

After messing around figured out that if single quotes are used instead of double quotes the tool doesn't properly process the builder.XXXXX commands. Using the debugger it seems like those commands are specially cut out and ran through C++ so I'm guessing the code doesn't properly extract the arguments. Same goes for builder.CreateFile('docx') ...only works for builder.CreateFile("docx").

For now will just use double quotes, but I typically use single quotes when writing javascript which is how I fell into this.

Thanks!

Call `Api.CreateImage` with url result broken file on Windows

  1. Run this script on Windows
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph, oDrawing;
oParagraph = oDocument.GetElement(0);
oDrawing = Api.CreateImage("https://api.onlyoffice.com/content/img/docbuilder/examples/coordinate_aspects.png", 60 * 36000, 35 * 36000);
oParagraph.AddDrawing(oDrawing);
builder.SaveFile("docx", "CreateImage.docx");
builder.CloseFile();

In result will be created broken file of 1KB size.

This issue only actual on Windows, on centos and ubuntu everything is fine.
Also Api.CreateImage will not result broken file if use base64 inside

Tested on:

Windows 10
v5.3.3.30
sdk version:  5.3.3 (build:61)

DocumentBuilder C++ API: Convert DOCX to PDF failed with V8 error

Describe your problem:

I try to convert docx/xlsx file to pdf, but my program finished with:

TypeError: Cannot read property 'length' of undefined
    at Object.a.AscCommon.NU.decode.a.AscCommon.NU.decode (<anonymous>:11662:172)
    at e (<anonymous>:11577:526)
    at n.au (<anonymous>:11597:402)
    at Object.au (<anonymous>:11602:10)
    at e.vGd (<anonymous>:10401:495)
    at e.vGd (<anonymous>:10704:213)
    at <anonymous>:10345:382
    at da (<anonymous>:9653:313)
    at Object.a.AscCommon.aQh (<anonymous>:9835:127)
    at e.yO (<anonymous>:10345:345)

#
# Fatal error in v8::ToLocalChecked
# Empty MaybeLocal.
#

Steps to reproduce the problem:

compile and run C++ program based on your /opt/onlyoffice/documentbuilder/libdoctrenderer.so:

    using namespace NSDoctRenderer;
    CDocBuilder::Initialize(L"/opt/onlyoffice/documentbuilder");
    {
      CDocBuilder oBuilder;
      oBuilder.SetProperty("--work-directory", L"/opt/onlyoffice/documentbuilder");
      oBuilder.CreateFile(L"docx");
      oBuilder.SaveFile(L"pdf", L"my.pdf");
    }

the same error with xlsx:

 using namespace NSDoctRenderer;
 CDocBuilder::Initialize(L"/opt/onlyoffice/documentbuilder");
 {
   CDocBuilder oBuilder;
   oBuilder.SetProperty("--work-directory", L"/opt/onlyoffice/documentbuilder");
   oBuilder.CreateFile(L"xlsx");
   oBuilder.SaveFile(L"pdf", L"my.pdf");
 }

Here is the demo project https://github.com/anatoly-spb/onlyoffice-documentbuilder-cxx-api-demo

DocumentBuilder version:

8.0.0.99

Installation method:

rpm -ivh https://download.onlyoffice.com/install/desktop/docbuilder/linux/onlyoffice-documentbuilder.x86_64.rpm

Operating system:

CentOS 6
g++ (GCC) 11.4.1 20230605

terminate called after throwing an instance of 'std::regex_error' in `/opt/onlyoffice/documentbuilder/registration`

Current dev version cause

terminate called after throwing an instance of 'std::regex_error'
  what():  regex_error
Aborted (core dumped)

error on calling /opt/onlyoffice/documentbuilder/registration
Dockerfile:

FROM ubuntu:16.04

RUN echo "deb http://repo-doc-onlyoffice-com.s3.amazonaws.com/ubuntu/trusty/onlyoffice-documentbuilder/origin/develop/latest/amd64/ repo/" >> /etc/apt/sources.list.d/onlyoffice.list && \
    apt-get -y update && \
    apt-get -y --allow-unauthenticated install onlyoffice-documentbuilder=4.4.1-44
CMD /opt/onlyoffice/documentbuilder/registration

Stable version (4.3.2-7) not cause error:

FROM ubuntu:16.04

RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5
RUN echo "deb http://download.onlyoffice.com/repo/debian squeeze main" >> /etc/apt/sources.list.d/onlyoffice.list && \
    apt-get -y update && \
    apt-get -y install onlyoffice-documentbuilder=4.3.2-7
CMD /opt/onlyoffice/documentbuilder/registration

ContentControl delete invalid

  • builder version
    image

  • my code
    image

builder.OpenFile("test1.docx");
oDocument = Api.GetDocument();
oContentControls = oDocument.GetAllContentControls();
for (var i = oContentControls.length-1; i >= 0;i--)
{
    oContentControls[i].Delete(false);
}

oContentControls1 = oDocument.GetAllContentControls();
console.log("oContentControls1[0].GetClassType()");
console.log(oContentControls1[0].GetClassType());
console.log("oContentControls1.length")
console.log(oContentControls1.length)

builder.SaveFile("docx", "test2nocc.docx");
builder.CloseFile();
  • i want to delete ContentControl. it run no problem, but it is invalid.

  • print message

    oContentControls1[0].GetClassType()
    blockLvlSdt
    oContentControls1.length
    249

image

Unable to control formatting of multi-line text cells

When creating a Spreadsheet in OnlyOffice (or Calc, Excel, etc), it is possible to use Alt+Enter to add multiple lines of text to a single cell. When this is done, it is possible to highlight and format the individual lines, even individual characters within the cell.

DocumentBuilder allows me to use "\n" to force new lines in the value of a cell. But it doesn't seem possible to control the formatting beyond the level of the entire cell.

Using DocumentBuilder 6.2.0.123
Using Debian Linux

Allocation failed (out of memory) on version 5.1 (and possible on 5.0)

  1. Install latest onlyoffice-documentbuilder v5.1.0.3
  2. Create simple script test.js
builder.CreateFile("xlsx");
var oWorksheet = Api.GetActiveSheet();
oWorksheet.SetName("sheet 1");
oWorksheet.GetRange("A1").SetValue("Value");
builder.SaveFile("xlsx", "AddTextToSell.xlsx");
  1. Run documentbuilder test.js

Result:
Crash

<--- Last few GCs --->

   10732 ms: Scavenge 1397.7 (1445.0) -> 1397.7 (1445.0) MB, 26.2 / 0 ms [allocation failure].
   10760 ms: Scavenge 1397.7 (1445.0) -> 1397.7 (1445.0) MB, 28.0 / 0 ms [allocation failure].
   10785 ms: Scavenge 1397.7 (1445.0) -> 1397.7 (1445.0) MB, 24.8 / 0 ms [allocation failure].
   10822 ms: Scavenge 1397.7 (1445.0) -> 1397.7 (1445.0) MB, 36.6 / 0 ms [allocation failure].
   10849 ms: Scavenge 1397.7 (1445.0) -> 1397.7 (1445.0) MB, 27.0 / 0 ms [allocation failure].


<--- JS stacktrace --->
Cannot get stack trace in GC.

#
# Fatal error in MarkCompactCollector: semi-space copy, fallback in old gen

# Allocation failed - process out of memory
#

Illegal instruction (core dumped)

Tested on:
Debian 8
onlyoffice-documentbuilder v5.1.0.3

/opt/onlyoffice/documentbuilder/libcurl-gnutls.so.4: no version information available

  1. Create simple js example `test.js
builder.CreateFile("xlsx");
var oWorksheet = Api.GetActiveSheet();
oWorksheet.SetName("sheet 1");
oWorksheet.GetRange("A1").SetValue("Value");
builder.SaveFile("xlsx", "AddTextToSell.xlsx");
builder.CloseFile();
  1. run documentbuilder test.js

Result:

/opt/onlyoffice/documentbuilder/x2t: /opt/onlyoffice/documentbuilder/libcurl-gnutls.so.4: no version information available (required by /opt/onlyoffice/documentbuilder/x2t)

But file created fine

Tested on:
Centos Docker Image - Linux release 7.5.1804 (Core)

documentbuilder -v
v2.4.527.0
sdk version:  5.1.0 (build:25)

When using docbuilder files, temporary files are not deleted when done

Steps to reproduce the problem:

When is used docbuilder file for document conversion from XLSX to CSV, in OS temp folder (in this case /tmp) are left ascXXXXXX folders (where is X is random lower/upper case character). This happens when is called builder.SetTmpFolder at start of the script and this setting seems to be mostly respected for other temporary files.

Sample docbuilder file

builder.SetTmpFolder("/home/user/temp");
builder.OpenFile("/home/user/multiple_sheets.xlsx", "");
var sheets = Api.GetSheets();
sheets[0].SetActive();
builder.SaveFile("csv", "/home/user/out.csv", "");
builder.CloseFile();

DocumentBuilder version:
7.3.3, 7.4.0, Linux x86_64

Installation method:
Extracted RPM contents

Operating system:
CentOS 7, Ubuntu 20.04, likely others

There might be an issue with oParagraph.Search

I'm encountering an issue while using the oParagraph.Search method. When I attempt to bold the entire search result (e.g., "text"), only part of the text, like "tex," is getting bolded instead of the full "text" as I expected.

Aborted (core dumped) if LC_ALL not defined

  1. Install latest deb x32 docbuilder
dpkg -l | grep documentbuilder
ii  onlyoffice-documentbuilder         4.4.1-38                                   i386
  1. documentbuilder -v
v4.4.1.38
terminate called after throwing an instance of 'std::runtime_error'
  what():  locale::facet::_S_create_c_locale name not valid
Aborted (core dumped)

Tested on:
Ubuntu 16.04 x32

Docbuilder not returning non-zero exit codes on failure

Describe your problem:

When docbuilder fails running docbuilder file, exit code is always zero.

Steps to reproduce the problem:
This can be for example reproduced by running complex document conversion with memory limit

ulimit -v 1048576 && /opt/onlyoffice/docbuilder/docbuilder /tmp/oo-convert-script-3612931037

DocumentBuilder version:
7.4.0, Linux x86_x64

Operating system:
CentOS 7

Segmentation fault while running non-existing script on CentOS

  1. Install onlyoffice-documentbuilder
  2. Run onlyoffice-documentbuilder test

Result:

error: cannot read run file
Received signal 11 SEGV_MAPERR 007400000073

==== C stack trace ===============================

 [0x7fd36009d302]
 [0x7fd35f1f12f0]
 [0x7fd35f87ad5e]
 [0x000000401963]
 [0x7fd35f1dd445]
 [0x000000401d57]
[end of stack trace]
Segmentation fault (core dumped)

Tested on:
Centos Docker Image - Linux release 7.5.1804 (Core)

documentbuilder -v
v2.4.527.0
sdk version:  5.1.0 (build:25)

Everything is fine on

# documentbuilder -v
v4.4.1.50
sdk version:  4.4.1 (build:50)
documentbuilder test
error: cannot read run file

How can I batch operate Spreadsheet cells

i want to change Multiple cells'value
like
change
A B
1 a b
2 c d
to
A B
1 e f
2 g h

i need use SetValue() four times

is it possible
oWorksheet.GetRange("A1:B2").SetValue("e","f","g","h");

because i found documentbuilder spend to much time, and more script more time

Couldn't create temp folder under non-root user

Hi.

Thanks for this great product. I was trying the first example here https://api.onlyoffice.com/docbuilder/basic but it failed with a regular user with the following error :

Couldn't create temps folder
error: : save file error (1)

But, if i ran documentbuilder under the root user it works correctly.

I tested with a fresh installation on debian 9 and debian 10 (64 bit).
Adding builder.SetTmpFolder("DocBuilderTemp"); does not change nothing.

Feature Request: Support for Forms

ONLYOFFICE Docs v7.0 comes support for creating fillable forms.

It would be great if the Document Builder would also support generating forms.

Api.GetDocument().ToJSON(...) failed Footnotes are not supported?

docx file:
12.zip

file content:
2023-11-17_13-35

script code:

builder.OpenFile("12.docx");
var oDocumenta = Api.GetDocument();
console.log("--------0")
var aaa = oDocumenta.ToJSON(true, true, true, true, true, true);
console.log("--------1")
 GlobalVariable["aaa"] = aaa;
console.log("--------2")
var ca = oDocumenta.GetContent();
builder.SaveFile("docx", "out.docx")
builder.CloseFile();

result:
2023-11-17_13-37

exec command:

documentbuilder a1.docbuilder

allthemesgen errors: Cannot read property 'length' of undefined / Fatal error in v8::ToLocalChecked

Describe your problem:
When building onlyoffice, the step "allthemesgen" ends with segfault

Steps to reproduce the problem:
Use current (main) build_tools and go through build process, or use this dockerfile:

FROM ubuntu:20.04 as builder

ENV TZ=Etc/UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get -y update &&  \
    apt-get -y install git \
                       sudo \
			python3 \
			python

WORKDIR /root/

RUN git clone https://github.com/ONLYOFFICE/build_tools.git
RUN cd /root/build_tools/tools/linux/ && ./automate.py
RUN  cd  /root/build_tools/out/linux_64/onlyoffice/documentserver/ &&  LD_LIBRARY_PATH=${PWD}/server/FileConverter/bin server/tools/allthemesgen  --converter-dir="${PWD}/server/FileConverter/bin"   --src="${PWD}/sdkjs/slide/themes"   --output="${PWD}/sdkjs/common/Images"

build fails with error:
image

DocumentBuilder version: master

Installation method:

Operating system: Linux Ubuntu/Docker

`Range#select()` cause JS error `Uncaught TypeError: this.Uy.zta is not a function`

Describe your problem:

I need to replace some text in the spreadsheet, but replacetextsmart () doesn't work properly.

Be clear in your description of the problem.
Open an issue with a descriptive title and a summary in complete sentences.

I used the sample code in the API documentation
https://api.onlyoffice.com/docbuilder/spreadsheetapi/api/replacetextsmart

Operation results:

execute_run_code: oRange.Select();
execute_run: Uncaught TypeError: oRange.Select is not a function

If I delete the code that contains the “oRange”,Operation results:

execute_run_code: Api.ReplaceTextSmart(["Cell 1", "Cell 2"]);
execute_run: Uncaught TypeError: Api.ReplaceTextSmart is not a function

Steps to reproduce the problem:

  1. copy code from https://api.onlyoffice.com/docbuilder/spreadsheetapi/api/replacetextsmart
  2. save the code to the file demo.docbuilder
  3. excute command "docbuilder.exe demo.docbuilder"

DocumentBuilder version:
documentbuilder-4.4.1

Installation method:
Extract and use

Operating system:
Windows 10 20H2

Error when transferring `oTextPr` object via GlobalVariable

Integrate ONLYOFFICE Document Builder into my application on Node.js. Using globalvariable method to create paragraph object will cause errors.
Steps to reproduce the problem:
Exception Info:

Uncaught TypeError: Converting circular structure to JSON
--> starting at object with constructor 'cb'
--- property 'va' closes the circle

Script example:

builder.OpenFile("2022072-10000-81acb5fcd08244e3926c891263cfe168.docx");
var tempDocument = Api.GetDocument();
var tempDocumentParagraphs= tempDocument.GetElement(0);
GlobalVariable[ "CommentsReport" ] = tempDocumentParagraphs;
builder.CloseFile();
builder.OpenFile("2022072-10000-99c8b7f2ef844e97b6410eee0b0618c2.docx");
var curDocument = Api.GetDocument();
var oParagraph = Api.CreateParagraph();
var tempParagraph = global;
oParagraph.InsertParagraph(tempParagraph, "after" , true );
curDocument.Push(oParagraph); 
builder.SaveFile("docx", "Result4.docx");
builder.CloseFile();

Execution mode:
Run the above script with the executable file of docbuilder under the onlyoffice installation directory.
DocumentBuilder version:
Version: 7.1.1
Installation method:
Download and unpack on Windows .
Operating system:
Windows11

Support for fetch or other http request?

I'm looking for a way to extract form data in word
There is code similar to the following

let oforms = Api.GetDocument().GetAllForms();
let rs = {};
for (let oform of oforms){
	rs[oform.GetFormKey()] = oform.GetText();
}
fetch('http://myserver/document/builder/saveData/key',
{
    headers: {
      'Content-Type': 'application/json'
    },
    method: "POST",
    body: JSON.stringify(rs)
})

But it seems to fail silently because of ONLYOFFICE/DocumentServer#2361
Is there any way you can help me, thanks

Windows document builder cause MSVCR100.dll error

  1. Install current dev doc builder http://repo-doc-onlyoffice-com.s3.amazonaws.com/windows/onlyoffice-documentbuilder/origin/develop/latest/x86/onlyoffice-documentbuilder-4.4.1.35-x86.exe
  2. Run C:\ONLYOFFICE\DocumentBuilder\samples.bat

Result:

---------------------------
x2t.exe - System Error
---------------------------
The code execution cannot proceed because MSVCR100.dll was not found. Reinstalling the program may fix this problem. 
---------------------------
OK   
---------------------------

Tested on:
Win 10 x64

Api.CreateImage incorrect insert by https url in Web DocumentBuilder 5.1.4

  1. Send this script to url localhost/docbuilder?async=false
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph, oDrawing;
oParagraph = oDocument.GetElement(0);
oDrawing = Api.CreateImage("https://api.onlyoffice.com/content/img/docbuilder/examples/coordinate_aspects.png", 60 * 36000, 35 * 36000);
oParagraph.AddDrawing(oDrawing);
builder.SaveFile("docx", "CreateImage.docx");
builder.CloseFile();
  1. Download created file

In DocumentServer Web Documentbuilder 5.1.3 (and earlier) will be created this file (with correct inserted image)
CreateImage (2).docx

In DocumentServer Web Documentbuilder 5.1.4 will be created this file without correct image

May be related with new libcurl lib scheme
CreateImage (3).docx

poor performance when converting doc to pdf

Describe your problem:
I am keen on harnessing the capabilities of OnlyOffice to produce PDF documents for my clients. Despite an overwhelmingly positive overall experience, I've stumbled upon a performance hurdle when converting .docx files to .pdf on my server, which is noticeably sluggish.
From builder.sever part, I see the example code of using document builder. Like below:

`
// from document builder server
var BuildFile = function (inputFilePath, outputFilePath) {

child_process.execFileSync(builderPath, [inputFilePath], { cwd: path.dirname(builderPath) });

try {
fileSystem.accessSync(outputFilePath, fileSystem.F_OK);
} catch (e) {
throw "An error has occurred. Result File not found";
}
};`

It appears I'd have to initiate a separate process for each document conversion. Is it possible to launch a single child process and instruct it to carry out document conversions through Inter-Process Communication (IPC)? I'm dealing with hundreds of requests instantaneously and need to convert several hundred documents each second. Enhancing performance to reduce server resource consumption is crucial for me.

Be clear in your description of the problem.
It appears I'd have to initiate a separate process for each document conversion.

DocumentBuilder version:
newest

Installation method:
apt get install

Operating system:
linux

Chart Data in Presentation is not Editable

I'm following the presentation chart api documentation: (https://api.onlyoffice.com/docbuilder/presentationapi/api/createchart)

builder.CreateFile("pptx");
oPresentation = Api.GetPresentation();
oSlide = oPresentation.GetSlideByIndex(0);
oSlide.RemoveAllObjects();
oShape = Api.CreateChart("bar3D", [
  [200, 240, 280],
  [250, 260, 280]
], ["Projected Revenue", "Estimated Costs"], [2014, 2015, 2016], 4051300, 2347595, 24);
oShape.SetSize(300 * 36000, 130 * 36000);
oShape.SetPosition(608400, 1267200);
oSlide.AddObject(oShape);
builder.SaveFile("pptx", "CreateChart.pptx");
builder.CloseFile();

I've created a presentation without issue and the pptx file is viewable in powerpoint. However, if I right click on the resulting chart and try to edit the data, I'm met with the following error:
Screenshot 2022-02-15 at 17 00 05

This happens on both windows and macos, on both my local machine and on the onlyoffice api documentation page (link above).

For fun, I opened up the pptx (zip) file to see if there was an embedded xlsx file, and sure enough, it's there. The relation ID's seem to be correct, too. However when I attempt to open the xlsx file on its own in excel, I'm being told that there are issues with the file, and that excel needs to repair it. Here's the repair log:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
	<logFileName>Repair Result to Microsoft_Excel_Worksheet10.xml</logFileName>
	<summary>Errors were detected in file ’/Users/cameron/Downloads/presentation - 2022-02-15T163131.751/ppt/embeddings/Microsoft_Excel_Worksheet1.xlsx’</summary>
	<repairedRecords summary="Following is a list of repairs:">
		<repairedRecord>Repaired Records: Table from /xl/tables/table1.xml part (Table)</repairedRecord>
	</repairedRecords>
</recoveryLog>

Now here's the real trick: this occurs when using the API page I linked to above. The chart data is editable in your webapp, but not in powerpoint or excel, so I feel confident that the issue is not in my local setup.

Steps to reproduce the problem:

  1. Visit: https://api.onlyoffice.com/docbuilder/presentationapi/api/createchart
  2. Download file as pptx
  3. Attempt to edit chart data in powerpoint (right click chart > edit data)
  4. See issue

For posterity, here is the setup I am using locally:

DocumentBuilder version: v7.0.0.132 (sdk version: 7.0.0 (build:132))

Installation method: https://www.onlyoffice.com/en/download.aspx#builder (for centos)

Operating system: linux/centos

I've also attached an offending pptx file, though it's the exact one downloaded from your api docs.
Example Title.pptx

Failed to convert docx to pdf

my code:

builder.OpenFile("12.docx");
var oDocumenta = Api.GetDocument();
// GlobalVariable["aaa"] = oDocumenta.ToJSON(true, true, true, true, true, true);

var ca = oDocumenta.GetContent();
builder.SaveFile("pdf", "out.pdf")
builder.CloseFile();

but, exec script dir not exist out.pdf ?
This is what the official website demo says:
2023-11-17_13-26

only office version :

documentbuilder -v

v7.5.0.128
sdk version:  7.5.0 (build:128)

Build instructions missing

Hi.

I wanted to give the project a try, but i didn't find instruction for building it.

So after:

git clone --recurse-submodules  https://github.com/ONLYOFFICE/DocumentBuilder.git
cd DocumentBuilder && make

I get:

curl -L -o core/build/lib/linux_64/docbuilder.com.dll http://d2ettrnqo7v976.cloudfront.net/wrappers/linux_64/docbuilder.com.dll
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Warning: Failed to create the file core/build/lib/linux_64/docbuilder.com.dll: 
Warning: Aucun fichier ou dossier de ce type
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (23) Failed writing body (0 != 307)
make: *** [Makefile:87: core/build/lib/linux_64/docbuilder.com.dll] Error 23

And the script dependencies.sh is of no use.
I did try to build manually each part of the project, beginning with the core part:
cd core && ./make
And got this:

g++ -static-libstdc++ -static-libgcc -Wl,--rpath=./ -Wl,-O1 -shared -o libUnicodeConverter.so ../core_build/linux_64/release/obj/UnicodeConverter.o  /tmp/DocumentBuilder/core/Common/3dParty/icu/linux_64/build/libicuuc.so.58 /tmp/DocumentBuilder/core/Common/3dParty/icu/linux_64/build/libicudata.so.58 -lpthread  
g++: error: /tmp/DocumentBuilder/core/Common/3dParty/icu/linux_64/build/libicuuc.so.58: Aucun fichier ou dossier de ce type
g++: error: /tmp/DocumentBuilder/core/Common/3dParty/icu/linux_64/build/libicudata.so.58: Aucun fichier ou dossier de ce type
make[1]: *** [Makefile:161: ../../build/lib/linux_64/libUnicodeConverter.so] Error 1
make[1] : on quitte le répertoire « /tmp/DocumentBuilder/core/UnicodeConverter/UnicodeConverter.build »
make: *** [Makefile:278: build/lib/linux_64/libUnicodeConverter.so*] Error 2

Then I tried to build the dependencies:
cd core/Common/3dParty && ./make.sh
But there again, it failed (last lines):

../../src/objects-body-descriptors.h:101:22: note:   template argument deduction/substitution failed:
../../src/objects-body-descriptors.h:102:20: note:   candidate expects 2 arguments, 1 provided
     IterateBody(obj);
                    ^
cc1plus: all warnings being treated as errors
[79/1493] CXX obj/testing/gmock/gmock/gmock-spec-builders.o
ninja: build stopped: subcommand failed.

I could probably making more efforts into it, but I'm not sure about the project: is it really possible to build it ? Should'nt be there even a tiny documentation for building it ?

Thanks in advance.

How to set the label or tag for table cell in presentation?

Is there a method, let developer can set the label/tag for table cell (or inner paragraph of it) in presentation? I want to set the identification for table cells when create table by using Presentation API.

After that when I get the table data by api, I can also get every table cell's tag/label and text, then can establish a one-to-one mapping relationship for text and tag/label, like a form or json.

If existing api didn't support to achieve above result. Can I add some custom presentation api , by modify the source codes of document builder sdkjs ? For example, add SetLabel and GetLabel api for ApiTableCell or ApiParagraph method.

I also noticed there are SetLabel and GetLabel method for ApiBlockLvlSdt. But ApiBlockLvlSdt is only supported for Text document API, not Presentation API. Whether I can let Presentation API support ApiBlockLvlSdt by modify the source codes.

DocumentBuilder version: 8.0.1

I beg anyone can give me some ideas or advice, thanks.

odt file not created on develop

  1. Create simple script file test.js:
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
oParagraph.AddText("This is just a sample text. Nothing special.");
builder.SaveFile("odt", "AddText.odt");
builder.CloseFile();
  1. run documentbuilder test.js

Script exit, nothing happened, file not created.
Problem only for odt file, same script but with saving to txt or docx working fine

Tested on

documentbuilder -v
v5.5.99.1812
sdk version:  5.5.99 (build:1812)

Allocation failed on `builder.openFile`

  1. Create test.js
builder.OpenFile("only_paragraph.docx");
var oDocument = Api.GetDocument();
var oParagraph;
oParagraph = oDocument.GetElement(0);
oParagraph.SetJc("center");
oParagraph.AddText("Center");
builder.SaveFile("docx", "only_paragraph.docx");
  1. Place attached only_paragraph.docx in same folder
    only_paragraph.docx
  2. Run documentbuilder test.js

Result:

<--- Last few GCs --->

    9800 ms: Scavenge 1398.3 (1444.5) -> 1398.3 (1444.5) MB, 28.5 / 0 ms [allocation failure].
    9826 ms: Scavenge 1398.3 (1444.5) -> 1398.3 (1444.5) MB, 25.9 / 0 ms [allocation failure].
    9853 ms: Scavenge 1398.3 (1444.5) -> 1398.3 (1444.5) MB, 26.9 / 0 ms [allocation failure].
    9880 ms: Scavenge 1398.3 (1444.5) -> 1398.3 (1444.5) MB, 27.4 / 0 ms [allocation failure].
    9905 ms: Scavenge 1398.3 (1444.5) -> 1398.3 (1444.5) MB, 24.7 / 0 ms [allocation failure].


<--- JS stacktrace --->
Cannot get stack trace in GC.

#
# Fatal error in MarkCompactCollector: semi-space copy, fallback in old gen

# Allocation failed - process out of memory
#

Illegal instruction (core dumped)

Tested on:
Ubuntu 16.04

documentbuilder -v
v5.1.0.5
sdk version:  5.1.0 (build:5)

x64 centos/debian cause window.Asc.asc_docs_api is not a constructor

I have successfully compiled OnlyOffice, but when I launch the interface, an error will appear,:
image

but this will not affect the start of the service. Then when I visited the interface, I couldn't access it;
The log is :
image
I don't where is wrong,can't to find problems.
Please help me.Thank you so much .

get a segment fault running example code

Describe your problem:
I run the example code of C++ BUILDER.FRAMEWORK api, but got a segment fault error on this line 'CContext oContext = oBuilder.GetContext();'
`
// Main function
int main(int argc, char* argv[])
{
CDocBuilder::Initialize(workDir);
CDocBuilder oBuilder;
oBuilder.SetProperty("--work-directory", workDir);

oBuilder.CreateFile(fileExtension);

CContext oContext = oBuilder.GetContext();
CContextScope oScope = oContext.CreateScope();

CValue oGlobal = oContext.GetGlobal();

CValue oApi = oGlobal["Api"];
CValue oDocument = oApi.Call("GetDocument");
CValue oParagraph = oApi.Call("CreateParagraph");
oParagraph.Call("SetSpacingAfter", 1000, false);
oParagraph.Call("AddText", "Hello, world!");
CValue oContent = oContext.CreateArray(1);
oContent[0] = oParagraph;
oDocument.Call("InsertContent", oContent);

oBuilder.SaveFile(fileExtension, sDstPath);
oBuilder.CloseFile();

CDocBuilder::Dispose();

return 0;

}
`
Steps to reproduce the problem:

  1. download the code, 'https://github.com/lqzerogg/docbuildertest'
  2. mkdir docbuildertest/build && cd docubuildertest/build
  3. cmake ../
  4. make
  5. ./main

DocumentBuilder version:
v8.0.0.99

Installation method:
download from this website 'https://www.onlyoffice.com/download-builder.aspx?from=api'. then install locally.
sudo apt install ./onlyoffice-documentbuilder_amd64.deb

Operating system:
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

DocumentBuilder generate file success but the content is empty

I successfully compiled the douctment builder and successfully ran the examples in it, but when I used c++ API to generate files, I also successfully compiled the project use vs2017 win10, but the contents of the files are empty, including docx, rtf, txt and so on.
the cpp example is coppy from https://api.onlyoffice.com/docbuilder/integrationapi/cdocbuilder

image
the file can generate but the content is empty.the docbuilder.exe can successfully to gengerate the samples
image
i have no idea about how to sove it,Is there anything wrong in cpp file?

Handle fonts from `~/.local/share/fonts`

Given the following document:

Screenshot from 2020-04-30 17-11-12

And this document script:

builder.OpenFile("Manual.docx");
builder.SaveFile("pdf", "/tmp/Manual.pdf");
builder.CloseFile();

The resulting PDF does not contain the custom font:

Screenshot from 2020-04-30 17-11-51

I am running Linux Mint 19.3 Cinnamon.

AppImage

Is possible to make AppImage version?
I would like to see it, I am not using RPM or DEB systems.

Cenots 8 fonts requirements not match

  1. sudo dnf -y install epel-release
  2. sudo dnf -y install https://download.onlyoffice.com/repo/centos/main/noarch/onlyoffice-repo.noarch.rpm
  3. sudo dnf -y install onlyoffice-documentbuilder

Result:

Error: 
 Problem: conflicting requests
  - nothing provides dejavu-lgc-sans-fonts needed by onlyoffice-documentbuilder-5.3.3-43.x86_64
  - nothing provides dejavu-lgc-sans-mono-fonts needed by onlyoffice-documentbuilder-5.3.3-43.x86_64
  - nothing provides dejavu-lgc-serif-fonts needed by onlyoffice-documentbuilder-5.3.3-43.x86_64
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
[virtualbox@localhost ~]$ sudo dnf -y install onlyoffice-documentbuilder
Failed to set locale, defaulting to C
Last metadata expiration check: 0:00:58 ago on Fri Oct 25 10:54:45 2019.
Error: 
 Problem: conflicting requests
  - nothing provides dejavu-lgc-sans-fonts needed by onlyoffice-documentbuilder-5.3.3-43.x86_64
  - nothing provides dejavu-lgc-sans-mono-fonts needed by onlyoffice-documentbuilder-5.3.3-43.x86_64
  - nothing provides dejavu-lgc-serif-fonts needed by onlyoffice-documentbuilder-5.3.3-43.x86_64
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

Seems this error happened after some updates of repos, on 2019.10.16 with Centos:8 docker image everything was fine (ONLYOFFICE/doc-builder-testing#257)

How to add custom API for presentation to document builder?

I want to add some custom presentation API , by modify the source codes of document builder sdkjs.

For example, add GetAllTables method to sdkjs/slide/apiBuilder.js. Then I build the sdk-all.js by grunt, and replace the original sdk-all.js in my server.

/**
 * Returns an array with all the table objects from the slide.
 * @typeofeditors ["CPE"]
 * @returns {ApiTable[]} 
 * */
ApiSlide.prototype.GetAllTables = function(){
    var apiTables = [];
    if (this.Slide)
    {
        var drawingObjects = this.Slide.getDrawingObjects();
        for (var nObject = 0; nObject < drawingObjects.length; nObject++)
        {
            if (drawingObjects[nObject] instanceof AscFormat.CGraphicFrame)
                apiTables.push(new ApiTable(drawingObjects[nObject]));
        }
    }
       
    return apiTables;
};

But it cause javaScript error, even can't load the ppt as before.
screenshot

How can i add some custom API to document builder sdk?

I also try to read the codes. But can’t understand how these global variable like AscFormat import to context.

// global.js
var Asc;
var AscDFH;
var AscCH;
var AscFormat;
var AscFonts;
var AscCommon;
var AscCommonWord;
var AscCommonExcel;
var AscCommonSlide;
var AscBuilder;
var AscWord;
var AscMath;
var AscJsonConverter;
var AscCrypto;
var AscOForm;

Please tell me how to find the definition of these global variable. I want to know all the properties and methods of them.

DocumentBuilder version:
7.4.1

Operating system:
Server: centOS 7.9.0
Client: macOS Chrome 124.0.6367.78

Document Builder hangs when docubuilder file gets long

Describe your problem:

Document Builder seems to hang if a docubuilder file has longer than 2000 lines when creating an excel file.

Steps to reproduce the problem:

Create a docubuilder file with more than 2000 lines.
Try to create an Excel file out of it by running the binary.
The process will hang forever.

DocumentBuilder version:

[prudentcircle@fedora ~]$ documentbuilder -v
v7.3.3.52
sdk version: 7.3.3 (build:52)

Installation method:

RPM based installation on Fedora 36

Operating system:

Fedora 36
20230331_third_page2.docubuilder.txt

A table of contents in Word is invalid

after builder.OpenFile、builder.SaveFile , A table of contents in Word is invalid

builder.OpenFile("test.doc");
var oDocument = Api.GetDocument();
var oParagraph, oRun;
oParagraph = oDocument.GetElement(0);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Dear John Smith.");
oDocument.Push(oParagraph);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("ONLYOFFICE is glad to announce that starting today, you are appointed Commercial director to the company of your dream.");
oDocument.Push(oParagraph);
oParagraph = Api.CreateParagraph();
oRun = Api.CreateRun();
oRun.SetBold(true);
oRun.AddText("Please note: ");
oParagraph.AddElement(oRun);
oRun = Api.CreateRun();
oRun.AddText("this text is used to demonstrate the possibilities of ");
oParagraph.AddElement(oRun);
oRun = Api.CreateRun();
oRun.SetBold(true);
oRun.AddText("ONLYOFFICE Document Builder");
oParagraph.AddElement(oRun);
oRun = Api.CreateRun();
oRun.AddText(" and cannot be used as real appointment to the position in any real company.");
oParagraph.AddElement(oRun);
oDocument.Push(oParagraph);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Best regards,");
oParagraph.AddLineBreak();
oParagraph.AddText("ONLYOFFICE Document Builder Team");
oDocument.Push(oParagraph);
builder.SaveFile("docx", "SampleText.docx");
builder.CloseFile();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.