ONLYOFFICE / DocumentBuilder

ONLYOFFICE Document Builder is powerful text, spreadsheet, presentation and PDF generating tool
https://www.onlyoffice.com/document-builder.aspx
GNU Affero General Public License v3.0
111 stars 56 forks source link

get a segment fault running example code #132

Open lqzerogg opened 4 months ago

lqzerogg commented 4 months ago

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/"