C++ framework samples guide

Before you start

For the samples to work correctly, make sure that two conditions are met:

  1. ONLYOFFICE Document Builder is installed into default directory "C:/Program Files/ONLYOFFICE/DocumentBuilder" on your computer.

  2. The directory in which you are going to store the downloaded samples has general editing access to save files created by the Document Builder.

Download a sample

Download one of the Builder C++ samples archive and unzip it into a folder with general editing access.

Sample structure

C++ Builder sample structure

Each sample includes a code folder, an sln file, and a template file if the sample uses a template.
The code folder consists of a C++ program file and project files.

C++ Builder project file

Please note that the path to the DocBuilder .dll file in the project file is set to default. You can change the path in the Sample.vcxproj.user file if DocBuilder is located in a different directory on your computer.

Program structure

C# Builder program file
  • Include doctrenderer library C++ wrapper

  • Specify the paths to the Document Builder work directory, the result path (where the generated file will be saved), and the optional template path (if a template file will be used).

  • Create the main function (this function works with the DocBuilder methods to edit documents).

C# Builder builder function
  • Initialize the DocBuilder from the working directory. After that Builder opens or creates a file so that Context, Scope and Global classes can be accessed.

  • Edit file using DocBuilder API methods. Use Call method with the name and params of the API method you call as an arguments.

  • Save and close file after editing, then call the Dispose method to destroy DocBuilder.

Run the sample

Open .sln file inside the sample folder to build the project.
Run the program when the project is built.

Visual Studio build and run sample

Check the result

After program execution the result file will be saved to the result path. It's sample folder root by default.

C# Builder sample structure result file C# Builder sample folder result file

Open result file and check the result.

C# Builder result file