Here you can find some code samples for Document Builder library in different programming languages:
For running C++ and C# code samples use python script configure/configure.py
which is able to generate:
- Visual Studio project files
- Qt project file
- Makefile
To use configure.py
you need to specify following options:
-
Which project files to generate:
--vs
,--qt
or--make
. Several options are available at the same time, but some of them are not supported on all platforms. In case you provide none of these options, all available projects will be generated. -
Test samples with
--test TEST
. Some available options:--test all
– generate projects for both C++ and C#.--test cpp
– generate projects only for C++ samples--test cs
– generate projects only for C# samples.--test cpp/creating_basic_form
– generate only project for the specified sample.
Several test options are available at the same time. To see all available
TEST
options callconfigure.py -l
. -
Directory to the Document Builder with
--dir DIR
. If Document Builder is not installed in default path you have to provide path to it.
Generated files will be located in the out
directory inside of the corresponding test folders.
NOTE: Only available on Windows
-
Use
configure.py
to generate VS project files. For example:python configure.py --vs --test cpp/creating_basic_form --test cpp/creating_advanced_form
-
Open
.sln
file in Visual Studio. It will prompt you to retarget Windows SDK and VS toolset to your installed version – click "OK". -
The solution is ready to be built and run. Documents will be created in the project files directory.
-
Use
configure.py
to generate Qt project files. For example:python configure.py --qt --test cpp
-
Open
.pro
file in Qt Creator. -
The project is ready to be built and run. Documents will be created in the
build
directory.
NOTE: Only available on Linux and Mac OS.
-
Use
configure.py
to generate Makefile. For example:python configure.py --make --test cpp/filling_spreadsheet
-
Go to the directory with generated Makefile:
cd ../out/cpp/filling_spreadsheet
-
Call
make
make
will build and run the executable. Documents will be created in the same directory as Makefile is.
NOTE: Only available on Windows with Visual Studio and .NET SDK installed
-
Use
configure.py
to generate VS project files. For example:python configure.py --vs --test cs
-
Open
.sln
file in Visual Studio. Depending on your installed .NET SDK version you may need to set different target framework by setting it in Visual Studio project properties or editing it directly in the.csproj
file. -
The solution is ready to be built and run. Documents will be created in the project files directory.
-
Execute
configure.py
with--test python
:python configure.py --test python
Provide directory to Document Builder with
--dir
if necessary.It is needed for generating auxiliary module containing the path to Document Builder.
-
Go to test directory:
cd python/creating_basic_form
-
Run the script
python main.py
Documents will be created in the test directory.
NOTE: JDK 8 or newer is required
-
Go to test directory:
cd java/creating_presentation
-
Compile the
Program.java
providing the path to docbuilder.jar, located in the Document Builder directory:javac -cp "C:\Program Files\ONLYOFFICE\DocumentBuilder\docbuilder.jar" Program.java
-
.class
file should appear in the directory. Run the program:java -cp "C:\Program Files\ONLYOFFICE\DocumentBuilder\docbuilder.jar;." Program
Note, that on UNIX systems the path separator is
:
instead of;
. Thus, on Linux or Mac OS it should be:java -cp "/opt/onlyoffice/documentbuilder/docbuilder.jar:." Program
-
Documents will be created in the test directory.