Qoppa’s Java library jPDFPrint can send PDF documents to a printer with standard print commands for text, images and shapes, but sometimes it may be necessary to send PDF pages to the printer as images rather than vector content due to the issues below: Occasionally, when the PDF content is very complex, some of the […]
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.
PAdES PDF Avanced Electronic Signatures Support in Qoppa PDF SDK
Does Qoppa’s PDF API support signing using “Advanced Electronic Signatures (AdES)”, as recognized by eIDAS regulation? Qoppa’s PDF library and components currently support the following digital signature types: • PKCS7 Signatures • B-B PAdES signatures • B-T PAdES signatures Qoppa’s PDF library and components currently do not support the following types of signatures (which are […]
Merging signed PDFs with Java PDF SDK jPDFProcess
Q: When merging signed PDFs or assembling pages from signed PDFs, jPDFProcess is throwing permission exceptions. How can I get around this? A: We try to prevent operations on signed PDFs that would invalidate digital signatures in PDF documents. This is so that customers do not invalidate signatures by accident. If you do not mind […]
Add Document TimeStamp (DTS) to a PDF document with Java
Using Qoppa’s PDF library products, jPDProcess and jPDFSecure, it is possible to add a Document Time Stamp (DTS added in PDF 2.0) to a PDF document. Here is a sample java program that does so. PDFDocument doc = new PDFDocument(in, null); // Invisible signature field SignatureField field = doc.getPage(0).addSignatureField("Signature1", new Rectangle2D.Double(0, 0, 0, 0)); […]
Search & Redact Social Security Numbers SSN in a PDF with Java
Here is a sample Java program to find all instances of social security numbers in a PDF document using a regex expression. Once the numbers are identified, they are removed from the PDF content and the area blacked out through a process called permanent redaction. The SSN are then covered with redaction annotations and removed […]
Can a digital signature in a PDF document have multiple linked widgets?
Q: We know that standard interactive form fields can have multiple widgets associated with them. In this case, all “linked” widgets in the document will contain the same form field data & have the same appearance stream. But how about digital signature fields? Do they allow multiple widgets to be associated with them? Answer: The […]
How to lock a PDF document when applying a digital signature in Java
Below is sample Java code showing how to lock a PDF document when applying a digital signature to it using jPDFSecure, Qoppa’s Java PDF Security SDK. // load PDF document into jPDFSecure PDFSecure pdf = new PDFSecure("c:/test/test01.pdf", null); // add a signature field SignatureField signField = pdf.addSignatureField(0, "sign here", new Rectangle(72, 72, 144, […]
Setting Highlight Mode for Link Annotations on a PDF Page
Starting v2020R2.05, the highlight mode for link annotations can be set using Qoppa’s PDF API jPDFProcess, jPDFNotes or jPDFEditor. There are 4 different highlight modes supported for links: Highlight Mode Inverted Highlight Mode Outline Highlight Mode Push Highlight Mode None Link link = (Link) annot; link.setHighlightMode(Link.HIGHTLIGHT_MODE_INVERT); //link.setHighlightMode(Link.HIGHTLIGHT_MODE_OUTLINE); //link.setHighlightMode(Link.HIGHTLIGHT_MODE_PUSH); //link.setHighlightMode(Link.HIGHTLIGHT_MODE_NONE);Link link = (Link) annot; link.setHighlightMode(Link.HIGHTLIGHT_MODE_INVERT); //link.setHighlightMode(Link.HIGHTLIGHT_MODE_OUTLINE); […]
Change Text Content Color in a PDF Document
Starting in v2020R2.03+, Qoppa’s PDF API, jPDFProcess, can get and set text color in a PDF document. This sample shows how to change text content color in a PDF from a given color to a new color. It gets the TextContent object and group text into spans by text fill color and as lines of […]
Create a Link in a PDF with Launch Action and Window Open Preference
This sample shows how to add a Link in a PDF document with a LaunchAction with specified open preferences: Open in a new window: Action.OPEN_NEW_WINDOW Open in the existing window: Action.OPEN_EXISTING_WINDOW Window set by user preference: Action.OPEN_USER_PREFERENCE // create a new link Link link = page.getDocument().getAnnotationFactory().createLink(); // show blue border around the link link.setRectangle(bounds); […]
Add a multi-line text rubber stamp to a PDF with dynamic date
Here is a sample java code showing how to add a multi-line text stamp to a PDF document using jPDFProcess public API. This will automatically add a rounded corner around the text. In this case, we’re creating a stamp that reads “Approved ” on the first line and has the current date on the second […]
Sign a PDF document with Java & Azure
Qoppa has 2 Java libraries that can apply signatures to a PDF document: jPDFSecure and jPDFProcess. To allow signature calculation with external signature appliances such as hardware security modules (HSM), we’ve defined a ContentSigner interface in our API, which allows our libraries to send the PDF content data to be signed externally and then receive […]
Sign a PDF document with 2 digital signatures
Here is some sample code showing how to use Qoppa’s Java PDF library jPDFSecure to apply 2 digital signatures to the same document or in other words, to sign a PDF document twice. This code can be very simply adpated to use our other library jPDFProcess and a PDFDocument object instead of a PDFSecure object. […]
Which hash algorithm is used when applying digital signatures
Qoppa’s PDF libraries components (v2020 and up) and Android PDF toolkit (v6.8 and up) use the safest hash algorithm available and supported by the PDF file version when applying digital signatures. This is priority order in which we look for hash algorithms based on the document version: PDF File Version 1.7 & up: “SHA512”, “SHA384”, […]
Setting or Changing PDF File Version
Users might need to change the file version of PDF documents for reasons such as compatibility with other software, or compatibility with features supported in the file version… Note that by default, when jPDFProcess creates a PDF document, the file version number is set to 1.7. Here is sample Java code to change the file […]
Java SDK Search (and Redact) Text Using Regular Expressions in PDF Documents
The Java sample program below shows how to search formatted fields in a PDF document (such as Social Security Numbers, email addresses, phone numbers or dates), apply redaction annotations and then burn them to remove the underlying text content. Formatted text is identified through the use of regular expressions (“regex”), so the code can be […]
Resolve Error “JCE Provider does not support SHA hash algorithm”
Q: I am building a web application to sign a PDF document with a given .pfx key store. I am running Spring Boot and using Qoppa’s PDF library jPDFSecure. I am getting an exception which states “JCE Provider does not support SHA hash algorithm”. How can I resolve this error? com.qoppa.pdf.PDFException: JCE Provider does not […]
List all embedded fonts in a PDF document
In version v2019R1, we’ve added a public API in our Java PDF Library jPDFProcess to tell whether a font is embedded in a PDF document or not. This is done through a method called isEmbedded in the IFontResource interface, that returns a boolean. The sample code below will get the list of all font resources […]
Merge all PDF files contained in a folder as a new PDF document
Here is a sample java program showing how to merge all the PDF files contained in a folder as a new merged PDF document and save it to a new file. This program uses Qoppa’s library jPDFProcess. It can easily be adapted to use jPDFAssemble as well. // create a new PDF document PDFDocument mergePDF […]
Checking for Form Field Flags such as Required, Read-Only, Rich Text
As of v2018R1, it is possible to get information about form field flags in Qoppa’s PDF libraries and components. These flags represent some of the field properties that can be found under the form field properties in PDF editing applications and our PDF components. Field Flags Available Interface FormField (available in all fields) FormField.FF_READONLY -The […]
Flatten & Merge 2 PDFs into 1 with Java
Here is a sample java program that uses Qoppa’s PDF library jPDFProcess to open two PDF files, flatten annotations and fields in each PDF document, then merge the two documents into one, and finally save the resulting merged document. // Load document 1 PDFDocument pdfDoc1 = new PDFDocument ("C:\\temp\\input1.pdf", null); // flatten annotations in document […]
Signature hash will not fit in allotted space
When signing using PKCS7 or PAdes with a timestamp server, you might receive the following exception: com.qoppa.pdf.PDFException: Signature hash (7895 bytes) will not fit in allotted space (7500 bytes).Increase timestamp server length estimate. To resolve this issue, you can increase the length estimate when defining the timestampserver parameters (the default length is originally set to […]
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 […]
List image properties of images contained in a PDF (color space, compression, width, height, etc…)
This sample code uses Qoppa’s PDF library jPDFProcess to list the properties of all images present in a PDF document such as image width, height, compression, color space, num components and bits per component: PDFDocument pdfDoc = new PDFDocument ("c:/test20.pdf", null); List<? extends IImageResource> imageList = pdfDoc.getResourceManager().listImages(); for (IImageResource image : imageList) { System.out.println(image.getWidth() + […]
Comparing Tesseract versions 3.02 and 3.05 for accuracy & performance
The Java PDF OCR module available in Qoppa PDF libraries currently runs on Tesseract 3.02. In June 1st 2017, Tesseract 3.05 was released and as a part of our 2018 software release cycle, we looked into upgrading the OCR module to use that version. Tests were done to compare Tesseract 3.02.02 against the new 3.05.01 […]
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 […]
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); […]
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 […]
Add a header image logo to an existing PDF
Here is a sample java program showing how to open a PDF, add a company logo image at the top of each page, then save the document using Qoppa’s PDF library jPDFProcess. // Load document PDFDocument pdfDoc = new PDFDocument ("C:\\myfolder\\input.pdf", null); // Load foreground image BufferedImage logoImage = ImageIO.read(new File("C:\\myfolder\\logo.jpg")); for (int […]
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 […]