PDFOne (for Java)
Create, edit, view, print & enhance PDF documents and forms in Java SE/EE
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 - BMP, PNG, JPEG and others. For converting to more formats such as TIFF, 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 Cloud-based document-processing
Gnostice StarDocs

Gnostice StarDocs is a scalable, fault-tolerant document-processing server solution, designed to be the central go-to place for all kinds of electronic document-processing work. StarDocs includes a web application (as seen at stardocs.gnostice.com) that frees your end-users from the need to have format-specific software to merge, split, redact, convert, edit, and sign documents - all they need is a network connection and a HTML5 browser. StarDocs provides a REST-based API that your developers can use to add document-processing functions to a variety of software applications. As the REST API is platform agnostic, your developers can write software on a wide variety of platforms - from desktop to mobile devices to Web services in any development language. To get them started quickly, StarDocs is supported by language-specific native SDK. StarDocs document server has load-balancing built-in and is designed to be scalable across enterprise Intranets and the Internet. StarDocs is available as packaged software for on-premise hosting and also as a subscription-based cloud service.

Our Delphi/C++Builder developer tools
XtremeDocumentStudio Delphi

Multi-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms.

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.

Our .NET Developer Tools
XtremeDocumentStudio .NET

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

PDFOne .NET

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

Our Java developer tools
XtremeDocumentStudio (for Java)

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

PDFOne (for Java)

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

Our office-productivity applications
Free PDF Reader

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

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