All the examples below can be downloaded within the SDK, together with the interfaces they use. Examples use 10 times larger pixel page size than the size in millimeters, to have large-enough pixel scale for more precise font mapping. Otherwise the drawing code can be the same for the screen as for the litePDF document.

helloworld – the simplest example, which prints a “Hello World!” text into a page. It demonstrates how to create a document, add a page, draw into it and save the document into a file. This example uses the C++ interface.

cppbuilder – a similar “Hello World!” example, but this time for a C++ Builder, which also uses the plain C++ interface. One difference is that it doesn't draw to an HDC, but to a TCanvas.

delphi – the last “Hello World!” example, which uses the Delphi interface. It's basically the same as the example for the C++ Builder, but completely written in the Pascal. It also contains Delphi version of attachments, docinfo, drawtoresource, encrypt, fromdoc, pagesperpage and sign examples, in a simplified form.

docinfo – this example demonstrates how to read and write information about the document. In consist of two parts. The first part writes a PDF document which has set information about an author and such to a file, then it reads the file from a disk and checks that the written values were the same as those read. Some of the values are Unicode strings.

dataops – this example shows how to create documents both direct file (write-only) and a memory-based documents. It mostly uses API for memory-based PDF documents. It contains several sections, which create a PDF document with a rounded filled rectangle on a page. Such document is saved into a file (directly, or through a memory buffer), same as the file loaded and re-saved. It also compares whether the result file content is the same for both save to a disk and save to a memory buffer.

incrementalupdate – this example shows how to incrementally update an existing document. It draws content to an existing and a new page, each version saved as the incremental update, then it also merges all the piled document versions into one and saves it.

drawtoresource – an example which draws an 'X' into a resource, and then draws it multiple times into a page, at different position and with different transformations, using the resource API of the litePDF library.

encrypt – this example creates four documents, each encrypted with a different algorithm (RC4 v1, RC4 v2, AES v2 and AES v3). One can be opened without a password prompt, while the other have set a 'user' and 'owner' passwords. After the documents are created, they are opened with different passwords. The example also shows how to deal with encrypted files when the password is not know (how to react on ERROR_WRONG_PASSWORD error).
Note: PoDoFo allows AES encryption for memory-based documents only.

fromdoc – this example demonstrates how to create a PDF file from an existing file, including page append and insert. It creates a source PDF document with three pages, on each is written the page number in the source document. Then it creates several documents based on it, namely one with only the second and the third page, one with the first page inserted as the second page and the last with the third page, after which is added a new page which has drawn the second page of the source document as a resource twice on it, and it finally inserts page 1 as the second page to the destination document.

pagesperpage – this example is similar as the fromdoc example, it only demonstrates other method of copying document content. It consist of two sections, the first creates a document with multiple pages. The second section opens the save document, checks the pages are the same size as they were written, then converts each page into a resource. The pages are deleted afterwards and the resources are drawn in a way of two-pages-per-page into the new document.

attachments – this example shows how to attach files, or custom data, into a PDF document, and how to extract these files from the document. The example also tests whether read data are the same as those written.

sign – this example shows how to prepare a signature field, digitally sign an existing PDF document and finally sign the prepared signature field, using the internal litePDF signing API, which allows PFX and PEM certificates to be used. The example also uses two signers for one signature field, but the Adobe Reader 11 shows only the first signer certificate, not both of them.

signmanual – this example shows how to digitally sign a PDF document, using Crypto API with a certificate stored in a .pfx file. The first part defines a simple signer class, MPdfSigner, which is responsible for signature operations and calls to Crypto API. The main part of the example creates a new document and signs it with help of the MPdfSigner, both to a file and to a memory buffer. The example shows how to add a visual annotation with an information about the signature on the second page of the document. It also signs already signed document, using the incremental update. Note that a page changes invalidate any previous signatures.

podofodocument – this example shows how to access the PoDoFo document. It creates a simple document and then checks how many internal objects contain a stream, which is printed at the end of the example. This is the only example which requires linking against litePDF.lib, due to usage of the PoDoFo classes.

bookmarks – this example shows how to create bookmarks and link anchors, which can help with navigation through the document.

unitvalues – this example shows how to work with different units. It creates a document with several pages, each created with a different unit and then reads the document and verifies that the stored page size matches the size used to create the page.

TOPlist