What is rasterizing a PDF file?
When you rasterize a PDF file, you convert the pages of the document into image files. The advantage of rasterizing the file is that the pages cannot be edited and a PDF viewer is no longer needed to display the pages. The disadvantage is that you lose all the features of the PDF file and Viewer and have all the limitations of a bitmap display.
To rasterize a PDF file, some additional software is needed. We will show you the process using JPedal and Java.
How to Rasterize a PDF file
Step 1 Download a trial copy of JPedal.
Step 2 Make sure your Computer has Java installed.
Step 3 Open up a Command line or console window
Step 4 Type in this command (adding in your own values).
java -jar jpedal.jar --convert "inputFileOrDir" "outputDir" png
If you are a Java Developer, you can also add this functionality into your own code.
How to Rasterize a PDF file in Java
Step 1 Download a trial copy of JPedal and add it to your IDE.
Step 2 Create a File handle, InputStream or URL pointing to the PDF file
ConvertPagesToImages extract=new ConvertPagesToImages(path);
Step 3 Include a password if file password protected
extract.setPassword("password");
Step 4 Open the PDF file
if (extract.openPDFFile()) {
Step 5 Iterate over the pages
int pageCount = extract.getPageCount();
for (int page = 1; page <= pageCount; page++) {
BufferedImage img = extract.getPageAsImage(page, hasAlpha);
}
}
Step 6 Close the PDF file
extract.closePDFfile();