use strict;
use CAM::PDF;
use Data::Printer;
my $doc1 = 'Document1.PDF';
my $draw1 = 'Drawing1.PDF';
my $newdoc1 = 'NewDocument1.PDF';
print "open the original document \n";
my $pdf1 = CAM::PDF->new($doc1);
my @prefs = $pdf1->getPrefs();
p (@prefs);
print "save it to the new location \n";
$pdf1->output($newdoc1);
print "open the new document \n";
$pdf1 = CAM::PDF->new($newdoc1);
print "open a drawing \n";
my $pdf2 = CAM::PDF->new($draw1);
print "append the drawing to the new document \n";
$pdf1->appendPDF($pdf2);
print "save the appended document \n";
$pdf1->output($newdoc1);
print "Done \n"
For clarity I did not include the "if not" code. This code opens the original document and saves it as the new document. Then it re-opens the new document and appends a drawing document and finally saves the combined document. Except that the save does not happen. The output is below:
open the original document
[
[0] undef,
[1] undef,
[2] 1,
[3] 1,
[4] 1,
[5] 1
]
save it to the new location
open the new document
open a drawing
append the drawing to the new document
save the appended document
Bad request for object 1121 at position 0 in the file
Use of uninitialized value in string eq at C:/Dwimperl/perl/site/lib/C
+AM/PDF.pm
line 4898.
Done
Press any key to continue . . .
The first save is ok and is the original document but the second save never happens and the appended drawing is missing.
|