Using documentbuilder's c++ api on Linux will docx to pdf errors

Subject: Does DocumentBuilder C++ API require Document Server? Conversion fails with V8 TypeError

Environment:

  • Ubuntu2404 x86_64
  • ONLYOFFICE DocumentBuilder 8.2
  • GCC 9.4.0

Issue:
When converting DOCX to PDF using the C++ API, we encounter:

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.
#

Full stack trace shows failure in V8 engine during decoding.
Code Implementation:

// main.cpp
#include "common.h"
#include "docbuilder.h"

using namespace NSDoctRenderer;

const wchar_t* workDir = L"/opt/onlyoffice/documentbuilder";
const wchar_t* filePath = L"/opt/onlyoffice/documentbuilder/empty/new.docx";
const wchar_t* resultPath = L"result.pdf";

int main()
{
    // initialize DocBuilder
    CDocBuilder::Initialize(workDir);
    CDocBuilder builder;
    builder.OpenFile(filePath, L"");

    // save as PDF and close
    builder.SaveFile(OFFICESTUDIO_FILE_DOCUMENT_OFORM_PDF, resultPath);
    builder.CloseFile();
    CDocBuilder::Dispose();
    return 0;
}

Compilation:

g++ -I/opt/onlyoffice/documentbuilder/include \
 -L/opt/onlyoffice/documentbuilder \
 -Wl,--unresolved-symbols=ignore-in-shared-libs main.cpp \
  -ldoctrenderer

Key Question:
Is the Document Server component required when using DocumentBuilder’s C++ API locally? The documentation is unclear about whether:

  1. DocumentBuilder is a standalone library
  2. The V8 errors imply missing backend services (like Document Server)
  3. This architecture requires both components

I found the same thing in the issue in this project’s github, and it doesn’t offer a solution

Hello @xwj

Can you please share a link to the mentioned issue in GitHub for better understanding of the context?

Answering the question directly - no, it is not required.

The github link for the corresponding problem: DocumentBuilder C++ API: Convert DOCX to PDF failed with V8 error · Issue #126 · ONLYOFFICE/DocumentBuilder · GitHub Even after setting the LD_LIBRARY_PATH=/opt/onlyoffice/documentbuilder environment variable it still doesn’t work.

Since there is an active discussion, you can freely ask for help in the issue. This way we’d avoid duplicates of the same discussion on several resources.

I don’t see a solution to this problem at the moment, so I’m here on the forum looking for help, do you guys have a solution?

We will do some tests to analyze the situation even further. Please await for my feedback.

Hello. Any update on the results?

Unfortunately, no news yet. This might take a while to replicate the environment, reproduce the situation and analyze it.

Okay, this should be relatively easy to reproduce, the use of the system is ubuntu2403, directly install the corresponding release version on github onlyoffice-documentbuilder_amd64.deb, using g++ compile and run the problem will appear, the follow-up has a solution please tell me please!

We have registered a bug on this issue for further investigation. I will keep you posted about the news.