Developer Tools
|
Office Productivity Applications
|
Platform-Agnostic APIs
|
Home | Online Demos | Downloads | Buy Now | Support | About Us | News | Working Together | Contact Us
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.
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 .NET Developer Tools | |
---|---|
Gnostice Document Studio .NETMulti-format document-processing component suite for .NET developers. |
PDFOne .NETA .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications. |
Our Delphi/C++Builder developer tools | |
---|---|
Gnostice Document Studio DelphiMulti-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms. |
eDocEngine VCLA Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools. |
PDFtoolkit VCLA Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents. |
Our Java developer tools | |
---|---|
Gnostice Document Studio JavaMulti-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 Platform-Agnostic Cloud and On-Premises APIs | |
---|---|
StarDocsCloud-hosted and On-Premises REST-based document-processing and document-viewing APIs |
Privacy | Legal | Feedback | Newsletter | Blog | Resellers | © 2002-2024 Gnostice Information Technologies Private Limited. All rights reserved. |