Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hey, folks!

Has anyone ever tried to work with PDF files using Perl? What I'd like to do is: given a PDF file, take page N and save it as another PDF file...

Thanks!

Replies are listed 'Best First'.
Re: PDF files
by runrig (Abbot) on Jul 03, 2001 at 23:33 UTC
    Have you looked for PDF on CPAN? Do any of those not do what you want?
Re: PDF files
by Maestro_007 (Hermit) on Jul 04, 2001 at 00:02 UTC
    There was a good post just today, XML2PDF. That post and its responses regarding PDFLib would be a great starting place!

    MM

Re: PDF files
by JojoLinkyBob (Scribe) on Jul 04, 2001 at 04:14 UTC
    Here's a fragment that might help, that might get you started at least:
    $fileheader_printed = 0; sub hash_figs { $figfile = $_[0]; open (fp, $figfile) || die ("Can't open $figfile.\nExiting"); $nodecount=0; $numpages=0; $ignore_text = 0; #Used to exclude page footer while (<fp>) { if (/^%!PS-Adobe/) #Start of Page Marker { if (++$numpages == 2) #Header is first element in list { if (!$fileheader_printed) { print @linelist; #print header $fileheader_printed = 1; } } else { if ("insert reg expr here") { print @linelist; #Print Figure } if ($nodecount++%80==0) { print STDERR "\n "; } } $currfig="junk"; @linelist = (); } elsif(m/^%%Title:/) { $currfig = uc $1; } elsif (/\[100 0 0 \-100 0 0\]\/Times\-Roman MF/) #Ignore Page Foot +er { $ignore_text = 1; } elsif (/Preamble/) #Ignore Page Footer { $ignore_text = 0; } if (not $ignore_text) { push (@linelist, $_); } } }
    Desert coder