PDF rasterizing to images

Posted on January 3, 2008. Filed under: Java |

Recently I played with several tools to generate images from pdf in Java. I tested with three libraries:
1. PDFBox http://www.pdfbox.org/
2. PDF Renderer
3. Acrobat Reader bean

Notice that Acrobat reader bean is provided Adobe freely but is very old (1999), PDF Renderer is a recent open source project by sun.

To summerize Acorbat reader java bean has the best rendering results, but it still present several special characters with error. PDFBox is decent but the font is strange, PDF Renderer has a lot of error but still generates the correct images.

Here are the code snippets for generating images using the above libraries:


import java.io.*;
import java.util.*;
import java.nio.*;
import java.nio.channels.*;
import java.awt.image.*;
import java.awt.*;
import javax.imageio.*;

import org.pdfbox.pdmodel.*;

public class pdf{
 public static void main(String [] args) throws Exception {
 String file = args[0];
PDDocument document = PDDocument.load(file);
 java.util.List pages = document.getDocumentCatalog().getAllPages();
 for(int i=0;i


Make a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Liked it here?
Why not try sites on the blogroll...

%d bloggers like this: