Having trouble diagnosing an issue with PDF::API2, where I have an existing PDF to bring in as a background/watermark/letterhead, and then I programmatically overlay text on top of that.

This is the code that brings in the background, before any text is overlaid on top:

my $xo = $pdf->importPageIntoForm( $bg_pdf, 1 ); my $gfx = $page->gfx(); $gfx->formimage( $xo, 0, 0, 1.0 );

This code runs fine, no errors -- and the $bg_pdf is a simple PDF v1.4 saved straight from Adobe Illustrator. But after some text is added by the script, the output is partially corrupted. That is, the imported letterhead PDF shows up to a point and then the rest is skipped/ignored until the overlaid text displays. For example, the letterhead includes several rectangles, and only a scant few show up in the generated PDF.

So it appears that upon display, the data for the existing background-pdf gets corrupted somehow, but the programmatic text overlaid on top, is just fine.

Early on I learned to turn off $pdf->{forcecompress} = 0; to keep the whole resulting PDF from being weirdly and randomly scrambled. So that shouldn't be pertinent here.

I've tried exporting the Illustrator PDF output in a number of different formats (v1.3, 1.4, 1.5); with or without 'preserve illustrator editing capabilities'; compression turned on or off; with including embedded fonts like garamond, vs using helvetica only, vs converting all text to outlines...

How does one go about troubleshooting this? Using PDF::API2 v2.038, in perl 5.30.0


In reply to Troubleshooting PDF::API2 overlaying text on an existing PDF by trillich

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.