Create, Convert and Manipulate PDFs using jRuby and Java PDF Library

Here is a jRuby script sample showing how to use Qoppa’s PDF library jPDFProcess to add text to an existing PDF document and write “Hello World” on the document. Using the flexible Java PDF library jPDProcess, any of the following functions could be performed: Add text and images to a PDF, print a PDF, convert […]

Read More

Customizing separators when extracting words in a PDF using jPDFText

Q: I need to extract words and position in a PDF. I am using getWordsWithPositions(int pageIndex) method in jPDFText. Having each word and its bounding quadrilateral is exactly what I need. However, I also need punctuation marks (ie ,;: . ) to be included as part of the words with bounding information. Is there a […]

Read More

Print PDF to Printer File Format (PCL, PRL, or PS) using Java

Here is a simple Java program showing how to use jPDFPrint to print a PDF document to a printer driver file format. In this example, the printer outputs a pcl file (Printer Command Language) but printers might output a prn file or postcript file. // Load the PDF document PDFPrint pdfPrint = new PDFPrint("input.pdf", null); […]

Read More

How to remove links in a PDF document

Here is a sample Java program showing how to remove all link annotations present in a PDF document using Qoppa’s PDF library jPDFProcess: // Load PDF document PDFDocument pdfDoc = new PDFDocument ("C:\\myfolder\\input.pdf", null); int pageCount = pdfDoc.getPageCount(); // loop through pages for (int i = 0; i < pageCount; i++) { try { PDFPage […]

Read More

JVM crash due to call to kcms.CMM.cmmColorConvert

Q: On a very specific PDF, our JVM crashes when converting PDF to images using Qoppa’s PDF library jPDFProcess. We’re running Java 1.7. This is a part of the hs_err_pid.log file. Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) J 6438 sun.java2d.cmm.kcms.CMM.cmmCombineTransforms([Lsun/java2d/cmm/kcms/ICC_Transform;Lsun/java2d/cmm/kcms/ICC_Transform;)I (0 bytes) @ 0x00007ffff3fa6243 [0x00007ffff3fa61e0+0x63] J 5050 C2 java.awt.image.ColorConvertOp.updateBITransform(Ljava/awt/color/ICC_Profile;Ljava/awt/color/ICC_Profile;)V (275 bytes) @ 0x00007ffff3ac2254 […]

Read More

How to add a ZUGFeRD invoice to a PDF document in Java using jPDFProcess

As of v2017R1.04, Qoppa’s Java PDF library jPDFProcess supports adding an electronic invoice in ZUGFeRD format to a PDF document as an XML file attachment or embedded file. Sample Java program showing how to attach an XML ZUGFeRD invoice to a PDF document using jPDFProcess: // Load the PDF document PDFDocument pdfDoc = new PDFDocument […]

Read More

Difference between PKCS11 and PKCS12

Though the names are very similar, PCKS11 and PKCS12 are actually defining 2 very different things and this can create some confusion. PKCS11 is a protocol used to access hardware encryption devices such as USB tokens, smart card or vaults (such as Azure Vault). Keystore API in Java allows to abstract access to the PKCS11 […]

Read More

Retrieving signature information from a signed PDF

This java sample program shows how to open a signed PDF and retrieve signature information from it such as signer’s name, sign reason, location, date, etc…. This sample uses Qoppa’s Java PDF Library jPDFSecure but can be easily changed to use jPDFProcess. // Load the signed document PDFSecure pdfDoc = new PDFSecure ("C:\\test\\output.pdf", null); if(pdfDoc.getSignatureFields() […]

Read More

Signing a PDF with a p12 file in Java

This is a sample java program showing how to sign a PDF document using a certificate loaded from a p12 file. The signature appearance is customized with an image, signer’s name and date. A signature field is added to the PDF document and then signed. This code uses jPDFSecure library but could very easily be adapted […]

Read More

Getting info for IRT Annotations: Reply to Annotations / Group Annotations

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 &lt; annots.size(); count++) { […]

Read More

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, […]

Read More

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 […]

Read More

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 = […]

Read More

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 * […]

Read More

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 […]

Read More

Invalid colors for CMYK images when cmykProfile.jar missing in 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, you will get images with “weird” colors. Faces for instance will show with more intense, bright saturated colors (such as red and blue) […]

Read More

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 […]

Read More

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 […]

Read More

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 […]

Read More

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 […]

Read More

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 […]

Read More