Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Keep It Simple, Stupid
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
use strict; use PDF::API2; use Carp; my $pdfile = "out.pdf"; my $pdf = PDF::API2->new( -file => $pdfile) or croak "can't open $pdfi +le as output"; #open a blank page my $page = $pdf->page; $page->mediabox ('A4'); my %font = ( Helvetica => { Roman => $pdf->corefont( 'Helvetica', -encoding => ' +latin1' ), }, ); # put some text my $header = $page->text; $header->font( $font{'Helvetica'}{'Roman'}, 24 ); $header->fillcolor('darkblue'); $header->translate( 50, 750); my $ht = "Hello, this is the first page"; $header->text($ht); # add pages from other .pdf files; my $include; foreach $include ("1_3.PDF", "1_4.PDF") { $page = $pdf->page; $page->mediabox ('A4'); my $include_object = PDF::API2->open($include); my $sourcepage = $include_object->openpage(1); my $xo = $pdf->importPageIntoForm($include_object, 1); my $gfx = $page->gfx; $gfx->formimage($xo, 0, 0, 1.0); } $pdf->save; $pdf->end();

The above code produces a .pdf file that's perferctly readable by ghostview, but causes an error in Reader XI. I need to produce a .pdf files that collates pages from different sources, inserting text pages that include computed information. The report will be used in a Windows 7 office environment in which avoiding acrobat is not an option.

The problem arises, I believe, when combining .pdf of the 1.3 and 1.4 standard, but the reason could be another. The input files and result are available for download at https://www.dropbox.com/sh/12jofjihcs67ph7/aPnL4y5xZb .

I tried both formimage and importpage, sprinkled some save/restore in the code, the 'pageencaps' option, but it didn't cut it.

My environment is strawberry perl v5.16.2 on Windows 7 32 bits. My version of PDF::API2 is 2.020 MSWin32

Thank you for your help!


In reply to PDF::API2 fails combining pdf 1.3 and 1.4 by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (7)
    As of 2014-04-20 16:48 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (485 votes), past polls