I'm looking at a Java library that can take PDFs and create a thumbnail image (PNG) from the first page .
I have already seen JPDL, but its crazy licensing fee is totally prohibitive. I am currently using iText to manipulate PDF files, but I believe this thumbnail generation does not work, I can use something like GhostScript on the command line, but if possible I I am hoping to keep the project all-inclusive.
is an LGPL licensed pure-Java library that makes it easy (taken from their example page Is):
file file = new file ("test.pdf"); RandomAccessFile RF = New RandomAccessFile (file, "R"); File channel channel = raf.getChannel (); Bytebuff Buff = Channel.map (filechannel mapmod.rade_only, 0, channel.image ()); PDFFile pdffile = new PDFFile (buf); // Create a first page on an image PDF page page; Pdffile.getPage (0); // Get the width and height for the doctor on the default zoom Rectangle rect = new rectangle (0,0, (int) page.getBBox (). GetWidth (), (int) page.getBBox (.) GetHeight ()); // Generate image image image = Page.Get image (fill. Background, print. Height, // width and height rect, // clip rick ct blank, // tap for image obscure, // fill background with white truth / / Blocking up to the drawing);
Comments
Post a Comment