[Pdfapi2-users] Newbie questions
Status: Beta
Brought to you by:
areibens
|
From: Ramm, H. <Hen...@me...> - 2003-10-28 13:05:00
|
Hello list,
I'm trying to combine some single page PDFs to one new multi-page PDF.
There should be a bookmark (outline) linking to every single page.
I found out, that combining pages works only if I
- set $pdf->{forcecompress}
(undocumented, guessed from example) if I omit that,
I get only errors
- open the collected file, import one page, save it.
If I try to import several pages, they get corrupted.
Regarding bookmarks:
- bookmarks of existing files don't get imported with their page
- I didn't manage to writ emore than one bookmark to my new file,
if I try to write the second, it can't find its "outline" method.
I'd like to know how to read information from existing files,
e.g. all the boxes, bookmarks etc. I tried to walk through all
objects of a PDF objects, but didn't find what I was looking for.
Any hints?
Here's my (simplified) code:
-------------------------------------------
#!/usr/bin/perl -w
use warnings;
use strict;
use PDF::API2;
my $Page =3D 0;
my $Filepattern =3D 'Page-###-Date.pdf';
my $Targetfile =3D 'Everything-Date.pdf';
my $Workdir =3D "D:/temp/"; # we're on Windows!
$Targetfile =3D $Workdir.$Targetfile;
my $CompletePDF =3D PDF::API2->new(-file =3D> $Targetfile);
$CompletePDF ->{forcecompress} =3D 0; # why?
my $Bookmark =3D $CompletePDF->outlines;
$CompletePDF ->saveas($Targetfile);
$CompletePDF ->end();
my $ok =3D 1;
while ($ok) {
$Page =3D sprintf "%03u", ++$Page;
my $File =3D $Workdir.$Filepattern;
$File =3D~ s/###/$Page/;
if (-f $File) { # while file exists
my $SinglePDF =3D PDF::API2->open($Datei);
$SinglePDF->{forcecompress} =3D 0; =09
$CompletePDF =3D PDF::API2->open($Targetfile);
$CompletePDF->{forcecompress} =3D 0;
$Bookmark =3D $CompletePDF->outlines
my $NewPage =3D $CompletePDF->importpage($SinglePDF, 0);
=09
#$Bookmark =3D $Bookmark->outline; # can't find outline method
after first page!
#$Bookmark->title("Page $Page");
#$Bookmark->dest($NewPage, -fith =3D> 1360);
$CompletePDF->saveas($Targetfile);
$CompletePDF->end();
$SinglePDF->end();
} else {
$ok =3D 0;
} # no more pages
} # while
$CompletePDF =3D PDF::API2->open($Targetfile);
$CompletePDF ->{forcecompress} =3D 0;
my %Info =3D $CompletePDF->info;
$Info{Title} =3D "S=FCdkurier";
$CompletePDF->info(%Info);
$CompletePDF->preferences(
-outlines =3D> 1,
-firstpage =3D> [ $CompletePDF->openpage(1), -fith =3D> 1360 ]
);
$CompletePDF->saveas($Targetfile);
$CompletePDF->end();
---------------------------------------------
--=20
Gr=FC=DFe vom Bodensee!
Henning Hraban Ramm
S=FCdkurier / MediaPro
Abt. Systementwicklung
|