This sample code shows how to get property information about reply to or grouped annotations annotations added to a PDF document. This functionality was open in the public API in v2017R1.1 in jPDFProcess library. PDFPage p = pdfDoc.getPage(i); Vector annots = p.getAnnotations(); if(annots != null) { for(int count = 0; count < annots.size(); count++) { […]
Category: jPDFProcess: Create/Manipulate PDFs
Developer library to create, print and manipulate PDF documents in Java. This library encompasses the functionality found in most of our other libraries.
Digital signatures and PDF/A compliance
Converting to PDF/A an existing Signed Document It is not possible to convert an existing PDF document that is already signed to PDF/A. This is because any changes that you make to a PDF even if it’s only adding PDF/A tags information in the metadata would invalidate the signature. If your PDF is already signed, […]
Setting Page Labels in a PDF document
With version v2017R1, jPDFProcess API has a new function to set page labels in a PDF documents. Look at the method called setPageLabels in the PDFDocument class. setPageLabels(int[] indices, String prefix, String style, int offset) throws PDFException Sets a page label to identify each page visually on the screen or in print. Consecutive pages create a labeling range using […]
Add a PAdES signature to a PDF document using Java library jPDFSecure, jPDFProcess
PDF 2.0 defines a new filter (Adobe.PPKLite) and sub-filter (ETSI.CAdES.detached) for PAdES signatures, which are compliant with the European eIDAS regulation. Support for PAdES was added in v2017R1 of Qoppa’s Java PDF libraries. This sample shows how to add a PAdES signature to a PDF document using Qoppa’s Java PDF library jPDFSecure. It is easy […]
Imposition of PDF pages using Java library jPDFProcess
This sample will open an existing PDF document, reorganize pages by putting 4 pages of any size onto one single page in letter format (8.5 x 11) and save them as a new PDF document. The pages are organized sequentially in 2 columns and 2 rows, called a sequential imposition layout. // Load document PDFDocument srcDoc = […]
How to resize pages in a PDF document with Java library jPDFProcess
Starting with v2017R1, Qoppa Java PDF library jPDFProcess offers an API to easily resize or change page sizes in a PDF document. The resize options are as follow: Media Box – new media box for the PDF Page. Center – option to center the page contents in the new media box (off by default) Auto […]
Error handling versus exception thrown when rendering PDF pages in jPDFImages and jPDFPrint
When rendering pages in a PDF document, jPDFPrint and jPDFImages may run into errors. In this case, the libraries will render the page with a red X drawn across the page, together with a message explaining what failed, such as “Error Handling Page: Missing Font”. Customers can choose to throw an exception instead, if they […]
jai image jars are not loading on some J2EE servers (need to scan for plugins)
Q: Even after adding the jai_imageio.jar and jai_codec.jar in the classpath, I am still getting an error when trying to save as Tiff and getting the “No TIFF Writers Available” exception. Any idea? A: There are some J2EE servers (such as Websphere?) that do not find ImageIO plugins automatically. Try any of the 2 calls […]
Embed a font in a PDF and write text content with the new font
This little sample code shows how to add a font to a PDF document and than add some text content to the PDF using this newly embedded font, using Qoppa’s PDF library jPDFProcess. // Create a blank document and add a page PDFDocument pdf = new PDFDocument(); PDFPage newPage = pdf.appendNewPage(8.5 * 72, 11 * […]
Two ways to add a barcode to a PDF document in Java using jPDFProcess
You can add barcodes to PDF documents with jPDFProcess in a couple of ways: You can use a barcode font, a font whose characters look like the barcode, and then add text to the document using this font. When the document is displayed, it will show the barcode (drawn using the font), and will have […]
Create, Merge and Convert PDF documents with Mule in an automated Worklow
Qoppa’s Java PDF libraries can be used within Mule ESB to automate PDF document processes within a workflow. PDF files can be transmitted as an input stream to any of our Java libraries. Follow the detailed steps showing how to integrate Qoppa’s PDF library jPDFProcess within a Mule flow. The following PDF functions available in […]
Invalid colors for CMYK images when cmykProfile.jar missing in classpath
Update: As of version v2019R1, cmykProfile.jar is now packaged inside Qoppa’s library jars and no longer requires to be added to the classpath. When rendering or optimizing images with a CMYK color space (DeviceCMYK), Qoppa’s PDF libraries and components need the cmykProfile.jar to be present in the classpath. If you forget to include this jar, […]
Create a PDF with a page and draw text and image on it using jPDFProcess
Sample program showing how to create a PDF using jPDFProcess. You first create a PDF, add a page to it then use the Graphics object form the page to draw onto it. On the page we draw text and an image. In this little snippet, the compression used for the image within the PDF document […]
Clear and delete signature fields in a PDF document using Java
This is sample Java program showing how to clear and delete signature fields in a PDF using Qoppa’s PDF library jPDFProcess. The jPDFProcess’ public API does not give a direct access to deleting fields in a PDF, but when deleting widgets which are the annotation associated with a field on a PDF page, it will […]
Search Text and Add Text Highlights & Markups in a PDF document
This java sample shows how to search text in a PDF and add text highlights or text markup annotations (underline, strikeout, squiggly) on top of the text using Qoppa’s PDF library jPDFProcess. // Open the document PDFDocument inDoc = new PDFDocument ("c:/input.pdf", null); // Loop through the pages, searching for text for (int pageIx […]
Filling field data in a PDF form programmatically with Java
To fill in the fields with data, you can use the getField() method to get a field by field name and then use the setValue() method to set the data. To set values in combo boxes and list fields, use values from the field’s export options and not the display options. To save the PDF […]
Search text in a PDF and add hyperlinks on top of the text found
This Java sample shows how to search text in a PDF document and add link annotations (that go to a specific URL) on top of the text occurrences found. This sample uses Qoppa’s PDF library jPDFProcess. // Load the document PDFDocument pdfDoc = new PDFDocument ("C:\\myfolder\\input.pdf", null); // this is my search label that […]
Search Labels and Redact Text in a PDF
This Java sample shows how to search a text label within a PDF document and then remove the text following that label. This is done by adding a redaction annotation and burning it which remove any content below the redaction annotation. This sample is using Qoppa’s PDF library jPDProcess In the sample code below, we’re […]
Setting / Editing PDF Document Properties & Metadata including Title, Subject, Author, Keywords
After creating or assembling a PDF document, it is a important to set or edit the meta data. Qoppa Java libraries jPDFAssemble and jPDFProcess can edit document properties and xml metadata such as title, author, subject and keywords. The sample java code below shows how to open a PDF, edit the document properties and then […]
Code Sample: Add Redaction Annotation to PDF, Export to XFDF, Import from XFDF
Here is a sample java program showing how to add a redaction annotation to a PDF document, export them as xfdf and then re-import them into another PDF document using Qoppa library jPDFProcess. // create a new PDF and append a page to it PDFDocument doc1 = new PDFDocument(); PDFPage page1 = doc1.appendNewPage(72 * 8.5, […]
Sample Java program to add layers to a PDF and add content onto the layers using jPDFProcess
Sample Java program showing how to add layers to a PDF document and to draw content on the new layers. jPDFProcess can draw onto new or existing layers, on new or existing documents / pages. // Create a new document PDFDocument pdf = new PDFDocument(); // Add a blank page to the document PDFPage […]
Deleting all bookmarks from a PDF document
To delete all bookmarks in a PDF document, simply create a new empty root bookmark. With jPDFProcess, use PDFDocument.createRootBookmark(); With jPDFAssemble, use PDFAssemble.createRootBookmark(); With jPDFEditor, use PDFEditorBean.getDocument().createRootBookmark(); Here is sample code to do so: // Load the document PDFDocument pdfDoc = new PDFDocument ("input.pdf", null); // Get the root bookmark, create one if necessary Bookmark […]
Clear Password and Permissions in a PDF document
It is possible to clear permissions and passwords in a PDF document using several of Qoppa’s Java PDF libraries and components. With jPDFSecure, use PDFSecure.clearPasswordPermissions() With jPDFProcess, use PDFDocument.clearPasswordPermissions() With jPDFEditor, use PDFEditorBean.getDocument().clearPasswordPermissions() Calling PDFSecure.clearPasswordPermissions will clear all password permissions for this document: it will reset all password permissions to true. it will clear open/user […]
Changing PDF Document Permissions and Passwords
It is possible to set / update permissions and passwords in a PDF document using several of Qoppa’s Java PDF libraries and components. Call to change document permissions and passwords depending on which Qoppa library you use: // with jPDFSecure PDFSecure.setPasswordPermissions(newPermPwd, newOpenPwd, permissions, currentPermPwd, encryptType); // with jPDFProcess PDFDocument.setPasswordPermissions(newPermPwd, newOpenPwd, permissions, currentPermPwd, encryptType); […]
How to Resolve Error Rendering Page: Missing Font
When rendering a PDF document in the following Qoppa’s PDF library products: jPDFImages, jPDFPrint, jPDFProcess, jPDFViewer, jPDFNotes or jPDFEditor, you might encounter a blank page with an “Error Rendering Page” displayed in red on a page. This error happens when there is an issue with a font within the PDF document. There are 2 possible […]
Fill / Populate XFA Dynamic Form with Field Data in Java
Here is a sample Java program that can load a dynamic XFA form, fill in data from an XDP or XML file and then saved the filled form. This sample is using Qoppa’s PDF library jPDFFields. It could be simply adapted to use jPDFProcess library by replacing PDFFields with PDFDocument. import com.qoppa.pdfFields.PDFFields; public class […]
Copying pages from one PDF to another PDF in Java
Here is a sample Java program that shows how to copy pages from one PDF document to another using Qoppa’s PDF library jPDFProcess. The sample can be adapted to work with Qoppa’s jPDFAssemble by simply replacing the class “PDFDocument” with “PDFAssemble”. In this sample, we’re copying the pages from an existing PDF to a new […]
Export PDF to PNG Image with Overprint Simulation
This Java sample below shows how to use Qoppa’s jPDFImages (or jPDFProcess) to load a PDF and export it to an image in PNG format with overprint simulation on. First, the image is rendered in CMYK profile, then converted to RGB using ColorConvertOp and finally saved as PNG (or JPEG). The resolution is set at […]
On using Java RenderingHints to smooth jagged edges on rotated images
Q: There seems to be some pixelation or resolution issue when rendering specific images in a PDF brochure. Is there anything that can be done to render these images more smoothly? A: Qoppa’s PDF libraries and components uses our own interpolation algorithm that works much better than the built-in Java algorithm well both when up-sampling […]
Is it possible to send CAC certificates to the server for digital signature?
Q: We are developing a webserver solution which will be deployed on Internet Explorer for digitally signing PDF documents. We need to sign using the certificate on the users CAC Card. Is it possible to get the certificate from the client to the server for signature? A: If you are using a hardware device for […]