in reply to CAM::PDF cleanoutput Error

Did the new() method succeed? Is the value of $newdoc1 what you think it is?

1 Peter 4:10

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

    I have coded this:

    if (!$pdf1) { print "Create PDF failed \n"; GETOUT; }

    Where the subroutine GETOUT does some graceful shut down but the code is never executed. I also tried eval with the same non-result.

    So, it seems the ->new() method returns something and, in the case of the ->output() method, it appears to be something CAM::PDF knows about.

    Also, even though ->output works in the first case, if I use ->appendPDF later in the code and try to save the result the ->output method will fail with the same 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

        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.