in reply to Re^2: CAM::PDF cleanoutput Error
in thread CAM::PDF cleanoutput Error

Perhaps the output functions clear out the document in memory? The docs don't explicitly say that, but it seems to match what you are observing.

1 Peter 4:10

Replies are listed 'Best First'.
Re^4: CAM::PDF cleanoutput Error
by Anonymous Monk on Nov 25, 2014 at 18:25 UTC

    A fair question. It seem I made a newbie mistake by not publishing the full code. Here it is:

    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.

      Here is something interesting. After trying several CAM::PDF external methods to see if anything has an effect on ->cleanoutput, I re-read the documentation and found a reference to ->cleanse, which is listed under "Routines that should not be called," in the context of throwing away unused font data.

      Well, I added it to my script anyway and now the combined document saves without error.

      So, I thought this is useful to pass along. Thanks for all the replies. I think this site is exceptionally helpful. Regards.