Re: PDF to scaled JPEG (thumbnail)
Re: PDF to scaled JPEG (thumbnail)
- Subject: Re: PDF to scaled JPEG (thumbnail)
- From: Hugi Thordarson <email@hidden>
- Date: Sun, 3 Apr 2005 18:35:15 +0000
There's a very nice library available called JPedal which is free if
you adhere to conditions of the GPL license, see http://www.jpedal.org/
.
Here's some simple example code I used to create a thumbnail from the
first page of a multi page PDF document. What this example does not
show you how to do is crop and scale the image and encode it into some
usable data. But there are plenty of examples of how to do that around
the web, so you shouldn't have any problems doing that :-).
import org.jpedal.PDFDecoder;
import java.awt.image.BufferedImage;
public BufferedImage bufferedImageFromPDFFilePath( String pdfFilePath )
{
PdfDecoder decoder = new PdfDecoder();
try {
decoder.setExtractionMode( 0, 72, 1 );
decoder.openPdfFile( pdfFilePath );
decoder.decodePage( 1 );
// This returns the page in its actual size. If you want a
thumbnail, you can also use getPageAsThumbnail( int, int )
BufferedImage image = decoder.getPageAsImage();
return image;
}
catch( Exception e ) {
System.out.println( e );
return null;
}
finally {
decoder.closePdfFile();
}
}
Hope this helps,
- Hugi
On 3.4.2005, at 16:07, Florijan Stamenkovic wrote:
Hi list...
I was looking for something that can:
Take data from NSData or a file that is a PDF and generate a jpg from
it (data or direct to file). And scale it preferably. I need it for a
context in which the user is uploading a pdf, and I need the
thumbnails to display them on my listings... I found some 599$
solutions :( and some free stuff, but nothing usable.
Does anybody do this, or knows of a working solution???
Florijan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden