This page describes a set of legacy sample programs delivered with the Adobe PDF Library software installation package.
This sample program opens a PDF document called addelem.PDF and adds an element to the pages in that document. The program adds a footer to each of those pages. The program creates PDEContent from each page, adds elements, and then gets elements from the content and edits the existing pages. The program then shifts the first line of each text run.
The Create Pattern sample program shows how to create tiling patterns in a PDF document.
Tiling is commonly used to render large BMP files by dividing a into a series of boxes, one right after another, left to right.
The program creates a new PDF document and a new page, adds content to that page, and saves the changes to a new output PDF document. Note that the program initializes and then terminates Adobe PDF Library.
The Decryption program demonstrates how to handle an encrypted PDF document. Specifically, you can use this program to decrypt a document that has already been encrypted using the standard security options in Adobe Acrobat.
The sample program starts with an input PDF document that was encrypted using Acrobat Standard Security, with 128-bit RC4 encryption and all applicable permissions denied.
The program shows how to authorize the PDF document open permission with the PDAuthProcEx callback, which requires the user password. Then, it also shows how to authorize permissions to operate on the contents of the encrypted document, which requires the master password. Finally,the program demonstrates reversing the page order (content extraction and document assembly).
The RC4 encryption algorithm, or Rivest Cipher 4, was developed by Ronald Rivest of RSA in 1987, and it remains a very popular software cipher for streamig data. It is also heavily used with Internet protocols such as the Transport Layer Security (TLS). RC4 is known for its speed and simplicity. But RC4 has been criticized for being vulerable in recent years. Microsoft recommends disabling RC4 if possible, and using the Advanced Encryption Standard (AES) instead. The description of the EncryptDocument sample program provides some more detail on encryption methods.
Form flattening removes dynamic form elements from a PDF form document and transfers them to the PDF page content stream, making them permanent parts of the PDF document. For example, the fields on a PDF form are converted into content fixed on the page. Radio buttons or dropdown menus are removed. If the original PDF document has a digital signature field, this field will be reduced to the name of the person who signed the document and related information, such as the date and time stamp.
This sample opens an input file called TransPDF.pdf, which features a transparent graphic object over another graphic, and flattens them so that the two objects are blended together.
See the description of the sample provided by Datalogics, FlattenTransparency.
The Fontembd sample program demonstrates font enumeration and embedding.
Enumerating fonts involves identifying the fonts available on a local system and selecting either the fonts referenced in a PDF document or the fonts that most closely match the fonts needed.
Font embedding places the entire font within your output file. This is a best practice for working with PDF, as by saving a font used by a PDF document within that document the viewing tool does not need to find the font on the local system, or substitute the original font used with another. However, a PDF document with all of the fonts used by that document embedded can be quite large. To help make the PDF document smaller, a subset of the characters in an embedded font can be selected to be added to the PDF document.
The program demonstrates using the PDEnumSysFonts() method to find a specific font, and using the kPDEFontCreateEmbedded flag when creating the font to embed the entire font in the PDF document.
It also shows how to use the kPDEFontCreateEmbedded and kPDEFontWillSubset flags together to embed and subset the font in a document, and shows the use of the PDEFontSubsetNow method after the text has been added to the PDEContent. That way, as text is added to the PDF document, the Adobe PDF Library will know what characters to subset in the font in that document.
This introductory program demonstrates the basics in creating a new PDF document. The program:
- Opens a new document
- Sets page size and inserts new page
- Creates a container for page content
- Selects a font
- Sets the text attributes
- Adds text to a text element
- Inserts the text element into page content
- Converts content into resource and content objects
- Places resource and content objects on the page
- Saves the new document
PDF documents normally compress graphics images that they contain, to reduce the size of the resulting file. One of the compressiong filters, or algorithms, used to compress graphics objects is the JPEG2000 encoding standard.
The JPXEncode sample program demonstrates re-encoding embedded image XObjects in a PDF document with the JPX filter. It then creates a new output PDF file, out.pdf, with the re-encoded images embedded in that file. The Image XObjects are encoded using the PDFEdit and COS layer APIs.
This program demonstrates how to merge two PDF documents into one, using an in-memory file system, and saves the result as an output PDF document.
The sample shows multiple threads creating PDF files simultaneously. The individual PDF files are then merged into one and written to a disk file by the main thread.
Note that we have a new sample program called MergeDocuments that also demonstrates this process.
This program shows how to use an in-memory file system for a simple workflow within a multi-threaded system. The program runs multiple threads to create several PDF documents simultaneously, and then merges them into a single document. You can set the number of threads to run and the number of jobs for those threads, as well as values like the font and page size. The program initializes and terminates Adobe PDF Library.
The MTSerialNums program opens a series of base PDF documents, each one under a separate thread, n and adds a serial number to that document. The program runs in a loop, continuing to supply auto-generated serial numbers for PDF documents until it receives a signal to stop.
Multiple threads can run at the same time in one system (multi-threading), using a processor that shares capacity with these threads. Or a computer may have multiple processors.
This sample program demonstrates the use of the WordFinder in a multi-threaded system. WordFinder is an Adobe Acrobat object that can identify all of the words in a PDF Document and create a list or table of those words, including the pages where each word appears, and the place of these words on each page.
The program uses PDDocCreateWordFinderEx to extract text from a document. WordFinder results are controlled through the PDWordFinderConfig and enumerated with PDWordFinderEnumWords().
For more information on these parameters in the PDWordFinderConfig structure see the Adobe Systems online Acrobat and PDF Library API Reference for PDWordFinder. This is provided as a separate download with the APDFL software installation package, and is also available from an Adobe Systems web site.
So you can also find information about WordFinder at the description of the TextSearch sample program.
The SnippetRunner is an application that executes snippets of APFL code. Individual snippets demonstrating API usage (not full samples) are located in the Snippets folder.
SnippetRunner allows you to quickly prototype code containing PDF Library API calls without the overhead of writing and verifying a complete application. It provides an infrastructure and utility functions to support execution and testing of code snippets, which are small but complete portions of PDF Library application code.
SnippetRunner is an application that acts as a back-end server and that provides basic features, including a parameter input mechanism, debug support, and exception handling. The application provides a user interface that works as a client to the back-end server. This user interface, called the Common User Interface, is also provided with the Adobe Acrobat SDK, which uses an Acrobat plug-in for its back end.
This sample converts PDF documents to PDF/A and PDF/X compliant PDF files. PDF/X is a standard format used for generating PDF proof pages for high-quality printing. Specifically APDFL can convert documents to the PDF/X-1a and PDF/X-3 formats. PDF/A, or PDF Archive, is a format used for creating PDF documents that are suitable for long-term storage. For example, to be certified as a PDF/A file, a PDF must have embedded fonts and cannot include audio or video attachments.
This sample program shows how to add hyperlinks, specifically those that access external web pages, (URIs), to an existing PDF document.
The program opens an external file containing key value pairs, where the key identifies a specific string and the value, the associated web address. Then it creates a word finder that populates tables of words sorted in PDF order and words sorted in x-y order. Finally the program adds a blue link annotation, traditionally associated with hyperlinks, over each of the matching keys in the PDF document.
PrintPDF demonstrates how to print a PDF document to both a printer and a PostScript file, using the Adobe PDF Library method called PDFLPrintDoc . The program manages PostScript parameters, such as those for controlling font embedding, scaling and the PostScript language level.
To work with this program you need to define the destination for the print document, either a file or a device. Note that the printer information is optional. The Adobe PDF Library can determine the correct device to use based on the installed printer.
Note also that the program offers several advanced properties:
- Pointer to Device Context (pDC). Do not use.
- Handle to Device Context (hDC). Provide a device context to the Library.
- Pointer to Device Mode (pDevMode)
- startResult. Communicates with the Windows GDI API.
These values are normally set to NULL. If you want to provide values for these advanced settings, to control the print loop, you need to set them completely, and correctly.
See the comments in the PrintPDF program.
This sample program opens an XPS file and converts it to a PDF document.
XPS refers to the XML Paper Specification file, an open file format created by Microsoft to serve as an alternative to the PDF format. You can create an XPS document using a variety of software products that allow printing, including any of the MS Office products, and an XPS file can be viewed, shared, and signed, but the content cannot be altered, and it must be opened using the XPS Viewer. Like a PDF document, the XPS file will appear the same regardless of system environment or platform.
See the description of the sample provided by Datalogics, XPStoPDF sample program.