PDFOne (for Java™)
Create, edit, view, print & enhance PDF documents and forms on Java™ platform
Compatibility
J2SE J2EE Windows Linux Mac (OS X)

Convert PDF To High-Resolution Images Using Java

Use PDFOne to export PDF pages to image formats.

Many companies send their bills as PDF documents. In most cases, the most useful part of the document is just the bill but unfortunately it will be buried under a whole lot of other pages.

Using PDFOne Java, we can just read the document, take a snap of the page where the bill is located, and save it as an image. This way the images will contain just the bills. Finding the bills in these images will be easier than opening the actual PDF documents.

In this tip, we will see how to accomplish this using one of the overloaded PdfDocument.saveAsImage() methods.

import java.io.IOException;

import com.gnostice.pdfone.PDFOne;
import com.gnostice.pdfone.PdfDocument;
import com.gnostice.pdfone.PdfException;


public class PdfSaveAsImage_Example {
  static {
    PDFOne.activate("your-activation-key",
                    "your-product-key");
  }

  public static void main(String[] args)
    throws IOException, PdfException {

    // Open a PDF document
    PdfDocument doc1 = new PdfDocument();
    doc1.load("Input_Docs\\sample_doc.pdf");

    // Save page 10 as a 96-dpi JPEG image
    doc1.saveAsImage("jpg",               // format
                     "10",                // page number
                     "image96_of_page#",  // image prefix
                     ".\\Output_Docs",    // output directory
                     96);                 // DPI

    // Save page 10 as a 204-dpi JPEG image
    doc1.saveAsImage("jpg", "10", "image204_of_page#", ".\\Output_Docs", 204);

    // Close the PDF document
    doc1.close();
  }
}

In the above code snippet, we export a PDF page at different resolutions - one at the common 96 dpi and another at a high 204 dpi. Keeping the source document as PDF turns out great for high-resolution image export. Check the results down below.

Screenshot 1: A sample PDF document. The invoice is on page 10
Screenshot 2: Image of the page at 96 DPI
Screenshot 3: Image of the page at 204 DPI

Did you add JAI and JAI Image IO libraries?

Java framework supports only a few image formats. For converting to other formats, you need to add the Java Advanced Imaging and Java Advanced Imaging Image IO libraries to your project.

You can download the JARs from:

---o0O0o---

Our Free Online Document-Processing Tools
Gnostice Apps

Gnostice Apps provides several PDF document-processing services over the Web. It enables you to merge, split, convert, secure and redact PDF documents - all for FREE. All you need to access these services is a HTML5-capable browser such as the latest version of Firefox/Seamonkey or IE 11.

Our Developer Tools
eDocEngine VCL

A Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools.

PDFtoolkit VCL

A Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents.

XtremePDFConverter VCL

A Delphi/C++Builder component to intelligently convert PDF to user-friendly Word RTF documents.

PDFOne .NET

A .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications.

XtremeDocumentStudio .NET

Multi-format document-processing component suite for .NET developers

PDFOne (for Java™)

A Java™ PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java™ applications.

XtremeFontEngine (for Java)

Java font engine to render glyphs from Type 1, Type 2 (CFF), and TrueType fonts

Our Office Productivity Applications
Free PDF Reader

A free, fast, and portable application for viewing, printing and converting PDF documents.

Privacy | Legal | Feedback | Newsletter | Resellers © 2002-2014 Gnostice Information Technologies Private Limited. All rights reserved.

This site is best viewed on a screen with minimum resolution of 1152 x 864 pixels. Windows XP users are advised to use Microsoft ClearType Tuning for optimal experience. Also, please use the latest version of a standards-compliant browser such as Firefox, Opera, or Dragon (Chromium).