Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PDF To JPEG Conversion

Status
Not open for further replies.

crn717

Programmer
Joined
May 25, 2007
Messages
1
Location
US
Hey Everyone,

I was wondering if someone could help me out. I have a Perl CGI script that needs to do the following:
[ol]
[li]Accept a PDF page number as input.[/li]

[li]Extract the page corresponding to the page number received in step 1 from a multiple-page PDF document.[/li]

[li]Convert the extracted page to a JPEG image and send it back to the browser.[/li]
[/ol]
On the surface, this initially appeared to be fairly simple. That is until I got to step 3. I used the PDF::Extract module for step 2 which made extracting a page out of a multiple-page PDF document extremely easy. However, finding a way to convert the extracted page to a JPEG image has been
challenging. I've searched CPAN fairly exhaustively for a module that could help but didn't really find anything. Basically, I was hoping I could find a module where I could do something like the following:
[blue]
[tt]
$m = SomeModule->new();
$m = SomeModule->load( $pdf_content );

$image = $SomeModule->convert_to_jpeg();

print( "Content-type: image/jpeg\n\n" );
print( $image );
[/tt]
[/blue]
However, as stated previously I didn't really find anything on CPAN. Does anyone have any suggestions on how I might go about handling step 3? Any help at all would be greatly appreciated. Thanks in advance.

Chris
 
ghostscript can for sure do what you are looking for. I've used it to print graphs created by Tk-Tcl, but it can also 'print' to a jpeg file.
It should be able to accept a PDF as the input; in the worst case you'll need to translate PDF to PostScript, and the PostScript to jpeg.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top