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 […]
Category: jPDFImages: Convert PDF To From Images
Developer library to create PDF documents from images or convert PDF documents to images in Java.
Getting PDF page size information, converting from points to inches, centimeters, millimeters
In Qoppa’s PDF libraries, the page width and page height are returned in points at 72 dpi. Here are the simple formulas to convert the page size to inches, centimeters and millimeters. // open PDF document PDFImages pdfDoc = new PDFImages ("C:\\myfile.pdf", null); // loop through pages for (int count = 0; count < […]
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, […]
Convert PDF document to PNG image files
This java program uses Qoppa’s jPDFImages to convert a PDF to PNG image files. A PNG image is created for each page contained in the PDF document. // open PDF document PDFImages pdfDoc = new PDFImages ("C:\\myfolder\\input.pdf", null); // loop through pages for (int count = 0; count < pdfDoc.getPageCount(); ++count) { // convert current […]
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 […]
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 […]
Export / Convert PDF Pages to Thumbnail Images with Java
Here is Java sample code to export PDF pages to images in various formats: PNG, JPG and TIFF using Qoppa’s PDF library jPDFImages. When opening the PDF document, the sample below read the document from a local file, the code can be simply changed to read the file from a file input stream instead. Export […]
Maximum Page Size / Resolution when converting a PDF to TIFF
Q: We are trying to export a PDF to TIFF using jPDFImages and are getting a Negative Array Size Exception. What could be the issue? Sample Code: public static void testPDFToTiff() throws Exception{ PDFImages pdf = new PDFImages("C:\\mydoc.pdf", null); TIFFOptions options = new TIFFOptions(300, TIFFOptions.TIFF_CCITT_T6); pdf.saveDocumentAsTIFF("C:\\mydoc.tif", options); }public static void testPDFToTiff() throws Exception{ PDFImages pdf […]
Invalid CMAP name when rendering or printing a PDF page
Q: When opening a PDF file, I get the following error: A: You are missing cmaps.jar in your classpath which contains CMaps, used to read and display character encodings used with CJK (Chinese, Japanese, Korean) content. Download cmaps.jar This error can happen when rendering PDF documents in Qoppa’s PDF components (jPDFViewer, jPDFNotes, jPDFEditor) or […]
How to hide the validation icon on signed digital signature fields
Q: Is there a way to turn off digital signature validity when rendering a PDF page in Qoppa’s PDF components and libraries? Our application will perform our own internal signature validation. A: Yes, it is possible by simply making a call to the following static method (before loading the signed PDF): PDFRenderHints.setRenderSignatureVerification(false);PDFRenderHints.setRenderSignatureVerification(false); This method sets […]
No Tiff Writer Available Exception when Converting PDF to Tiff
Q: I am using jPDFProcess to convert PDF to TIFF and getting the following exception. How can I resolve this exception? A: You need to add the jai image libraries in the classpath. jai_imageio.jar and jai_codec.jar are jar files that contain Java’s ImageIO image encoders and decoders, needed for reading and writing JPEG 2000 and TIFF files.
Packbits versus LZW compression for Tiff Images
Q: We are using jPDFImages to convert PDFs to Tiff and are using Packbits right now. Would the next best option be using LZW? What are the advantages and disadvantages of using LZW? A: Packbits compression is fast, widely-supported, and provides good results for scanned images. LZW provides more compression than Packbits but Packbits is […]
jPDFImages v2015R2 Build Notes
v2015R2.06 – June 15 2016 Added support for TrueType collections v2015R2.05 – June 8 2016 JPDF-776, JPDF-775 – Some fonts loading issues v2015R2.04 – May 23 2016 jPDF-762 – When importing TIFFs, default to 72 DPI when the data is “out of bounds”, that is: – If the resolution units in the TIFF are set […]
Is jPDFImages thread-safe?
Q: Once a PDFImages object is created, is it safe to share it between threads and call com.qoppa.pdfImages.PDFImages#savePageAsJPEG method from multiple threads on single object at once? A: Yes, PDFImages was developed to be thread-safe and for the same PDFImages object, i.e, for one PDF document loaded, it is safe to call savePageAsJEG from multiple […]
Monitoring time and memory used by a Java process using getThreadAllocatedBytes
A customer sent us this sample code today to monitor memory and time used by a Java thread when using our library jPDFImages to convert and save a PDF page to JPEG. This sample code can be generalized to monitor performance for any Qoppa library. This code only works for SUN JVMs. import com.qoppa.pdfImages.PDFImages; import […]
Export PDF Page as Image using CMYK or Custom Color Space
In version v2105R1, a new feature was added to our PDF to Image Conversion Library, jPDFImages, that allows rendering a page in a PDF document to CMYK color space or to any custom color space. Previous versions of the library would only render to the RGB color space which is typical when rendering to a […]
How to identify blank pages in a PDF programmatically
One way to tell if a page is empty in a PDF document is to look at the number of drawing commands on the page. If there is zero command then the page is perfectly empty, which usually means it was programmatically generated to be blank. But sometimes a page can contain a scanned image […]
Rendering to CMYK and Overprint Simulation
In version v2015R1, Overprint simulation was added to Qoppa’s Java PDF component jPDFEditor. This advance PDF technique is used by professionals in the print and pre-press industry. Overprint simulation allows to preview how two distinct colors that overlap will mix when printed. RGB Rendering By default, Qoppa renders to RGB: To render to CMYK […]
Code Sample: Convert Tiff to PDF in Java using flate, JBIG2 or JPEG compression
A Java program that converts a TIFF file into a PDF document using Qoppa’s library Java PDF image library jPDFImages. TIFF images cannot be inserted directly into a PDF, so we have to read them into an image object and then recompress. Using Flate Compression This sample below is the simplest way to convert a multi […]
jPDFImages Java API
Q: Where can I find jPDFImages javadoc API? A: You can find the API specification for the latest version of our library jPDFImages on our website at this link. jPDFImages is a java library to convert PDF documents to images and to create PDF documents from images in java.
Code Sample: Convert PDF page into BufferedImage in Java
A Java program that gets images from a PDF (one image per page) as Java BufferedImage objects using Qoppa’s library jPDFImages. Once images are available as BufferedImage objects, they can easily be modified before saving using Java Graphics2D. For instance here a watermark is applied to the images. Sample code, which uses jPDFImages library but can also be changed […]
Code Sample: Convert a PDF file to Tiff in java
A Java program to convert a PDF file to a single, multi-page TIFF file using Qoppa’s library Java PDF image library jPDFImages. import com.qoppa.pdf.TIFFOptions; import com.qoppa.pdfImages.PDFImages; public class PDFToTIFF { public static void main (String [] args) { try { PDFImages pdfDoc = new PDFImages ("input.pdf", null); TIFFOptions options = new TIFFOptions (150, TIFFOptions.TIFF_PACKBITS); pdfDoc.saveDocumentAsTIFF("output.tif", options); […]
Code Sample: Convert a PDF document to JPEG files in Java
This Java program converts a PDF file to multiple JPEG files using Qoppa’s library Java PDF image library jPDFImages. This program loops through the pages contained in a PDF document and outputs a JPEG image for each PDF page. In this program, the resolution is set to 150 dpi and the JPEG quality to 0.8. Both […]
Running in non-GUI / non windowing servers
Q: I am getting the following error when running your library jPDFPrint in our SunOS environment. How can I fix it? Exception in thread "main" java.lang.InternalError: Can’t connect to X11 window server using ‘localhost:0.0’ as the value of the DISPLAY variable. at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method) at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:134) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:141) at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62) at sun.awt.motif.MToolkit.<clinit>(MToolkit.java:81) […]