jPDFProcess Source Code Samples
Following are a number of Java samples that use jPDFProcess:
CreatePDFWithTextAndImage.java – This program will create a PDF, add a page to it and draw text and an image (loaded from a file) on it.
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.
AddImageLogo.java – This program will add a header logo image to each page of a PDF document.
AddBackgroundImage.java – This program will make a copy of a PDF (preserving all vector content) and add a background and foreground image.
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.
OCRPDFPages.java – OCR / Recognize and add Text to the pages of a PDF.
ResizePDFPages.java – Resize, rescale PDF pages, change media box in a PDF document.
CreateLayers.java – Creates a PDF document with two layers and adds some content to each layer.
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.
SearchAndAddLinks.java – Searches for a string and adds a URL link around it.
SearchAndHighlightText.java – Searches for a string and adds a highlight annotation on the string.
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.