jPDFProcess Source Code Samples
Following are a number of Java samples that use jPDFProcess:
SimpleMerge.java – This program will merge two PDF files into a single one.
SimplePrint.java – This program will print a PDF file to a named printer.
AddWatermark.java – This program will add a semi-transparent watermark to a document.
PDFToTIFF.java – This program converts a PDF file to a multi-page TIFF file.
FlattenFields.java – This program will “flatten” field data into the PDF content layer. This means that the field contents will become part of the PDF content and so the document will not be editable anymore.
SetPermissions.java – Encrypt the PDF document and restrict permissions.
ExportFields.java – Export field values in FDF format.
SignDocument.java – Apply a digital signature to a document. This program loads a document, then loads a digital ID from a PKCS#12 file, and then creates and signs a signature field on the first page of the document.
You can create a sample PKCS#12 file using Java’s keytool program. The command line to create a test file is as follows:
keytool -genkey -keystore test.pfx -storetype pkcs12 -storepass store_pwd -keypass key_pwd -alias key_alias
CustomSignature.java – This sample applies applies a digital signature to a document with a custom appearance. The appearance of signatures can be modified in jPDFProcess to include an image, choose the fields that show or custom text.
ExtractText.java – Extract text content from a document.
AddBookmarks.java – Adds a bookmark for every page in a document.
AddTOC.java – Creates a table of contents at the head of the document. This sample adds a page at the top of the document and then adds a page title and a link to every page in the document.
AddTextHighlight.java – Searches for occurrences of a text string and adds highlight annotations for the text if found.
TextRedaction.java – Searches for a string and redacts if from a document.
FileAttachments.java – Creates a PDF document and embeds 3 files as file attachments.
J2EEPDFFilter.java – Filter PDF files served from a J2EE server to add watermarks or inject additional content.