Using the VPE DLL / Shared Object

<< Click to Display Table of Contents >>

Navigation:  Programming Techniques >

Using the VPE DLL / Shared Object

Previous pageReturn to chapter overviewNext page

 

Note:For the VPE Control (.NET / ActiveX / VCL) there are examples for the first basic steps in using VPE in the "Control Reference" (VPE Control Reference.chm). Please read the introductory sections there and continue with the section “Preview” in this manual.

 

The common sequence of function calls is:

1.Open a document with the function VpeOpenDoc()

2.Use all possible methods to insert VPE objects (like text., etc.)

3.Use VpePageBreak() to generate new pages

4.Use VpePreviewDoc() to show the preview to the user, this is optional

5.Use VpePrintDoc() to print the document, or WriteDoc() to export it to PDF, HTML, etc.

6.Close the document with VpeCloseDoc()

 

NOTE:Preview and printing is only available for the Windows platform. On all other platforms you can generate VPE document files, as well as PDF and HTML (HTML output requires the Professional Edition or above).

 

You may open as many documents simultaneously as you like. The documents are identified by a unique handle (VpeHandle, which is a 32-bit integer on 32-bit platforms and a 64-bit integer on 64-bit platforms) with a value different from NULL, which is returned by VpeOpenDoc(). Use this handle in successive calls to the output functions.

Each document might send messages. The messages are received by the window, which is specified as parent-window in the first parameter of VpeOpenDoc(). On non-Windows platforms you can install a message callback function.

 

Example in C, which can be easily translated to other programming languages:

Windows platform:

void MakeDoc(HWND hWndParent)

{

 VpeHandle hDoc;

 

 hDoc = VpeOpenDoc(hWndParent, "Test", 0);

 VpeLine(hDoc, 1, 1, 5, 5);

 VpePreviewDoc(hDoc, NULL, VPE_SHOW_NORMAL);

}

A VPE document can exist without showing a preview. But if a preview is shown, the document is closed and removed from memory by default, when the preview is closed by the user or when the parent window is closed. If you call VpeEnableAutoDelete(hDoc, false), the document is not closed when the preview is closed.

The code above will bring up the preview window (without the "Monthly Report" text) shown in the next chapter.

 

All other platforms:

void MakeDoc()

{

 VpeHandle hDoc;

 

 hDoc = VpeOpenDoc(NULL, "Test", 0);

 VpeLine(hDoc, 1, 1, 5, 5);

 VpeWriteDoc(hDoc, "test.pdf");

 VpeCloseDoc(hDoc);

}

Generates a PDF file named "test.pdf". On non-Windows platforms you must always call VpeCloseDoc() to remove a document from memory.