<< Click to Display Table of Contents >> VPE Shared Object / Dylib |
![]() ![]() ![]() |
The following example is in C/C++, but can be easily translated to any other programming language. Write the following function and call it from the main() function of your application:
void MakeDoc(HWND hWndParent)
{
VpeHandle hDoc = VpeOpenDoc(NULL, "Test", 0);
VpeWriteBox(hDoc, 1, 1, 5, 1.5, "Hello World!");
VpeLine(hDoc, 1.5, 3, 5, 6.5);
VpeWriteDoc(hDoc, "hello world.pdf");
VpeCloseDoc(hDoc);
}
You must link your application against the VPE library, please consult the manuals of your linker on how to do this. On Linux for example, provide to the linker the switch "-lvpep" (vpep for the Professional Edition, vpex for the Enhanced Edition, vpes for the Standard Edition and vpec for the Community Edition).
Congratulations, this is your first program using VPE! The source code is self-explanatory, the only thing to explain are the numbers in the calls to WriteBox() and Line(): these are the coordinates in centimeters relative to the upper left corner of the page. The coordinates are organized as (left, top, right, bottom).
Note: you can also switch to inch units, so the coordinates are not in centimeters, but in inches.
Please note that this is a very very simple demo. For example, VPE can compute the width and height of a text object depending on the text-length and the chosen font. So you can position objects dynamically at runtime relative to each other, in contrast to a static layout.
We recommend to continue with the tutorial created by running the "vpedemo" executable, which comes with VPE. The demo named "Capabilities + Precision" creates a document with a handy 5-page tutorial (beginning on page 2 of the document).
The very detailed and in-depth explanation of all aspects and features of VPE can be found in this document in the chapter “Programming Techniques”.