Thanks for the code sample. I am able to replicate this problem, but on PDF 1.5+ files with cross reference streams only.

PDF::API2 is attempting to do an incremental-update; i.e. doing a byte-copy of the entire file, then writing just an update section.

One issue I can see is in the trailer. PDF::API writes:

xref 0 1 0000000000 65535 f trailer << /Type /XRef /DecodeParms << /Columns 4 /Predictor 12 >> /Filter /Fl +ateDecode /ID [ <0804b5bbf3a55e75ca368be05a5dbdf1> <49e68ac26e773d479 +329dad137f869c3> ] /Index [ 214 37 ] /Info 213 0 R /Length 86 /Prev 1 +16 /Root 215 0 R /Size 250 /W [ 1 2 1 ] >> startxref 106778 %%EOF
But the format should be more like:
xref 0 1 0000000000 65535 f trailer << /ID [ <0804b5bbf3a55e75ca368be05a5dbdf1> <49e68ac26e773d479329dad13 +7f869c3> ] /Info 213 0 R /Prev 116 /Root 215 0 R /Size 250 >> startxref 106780 %%EOF
It's leaving some irrelevant 1.5 entries in the file trailer (/Type, /Columns, /Predictor, /Filter, /Index, /Length /W ...) when writing a 1.4 format trailer. Could be other issues.

Needs a ticket. I'll raise one when I get some clicks.

In the short term you can try converting the PDF files to 1.4 and see if that helps.

Update: The Perl 6 PDF module also has similar issues (I'm the author). I've raised a ticket there first.

Update2:
- hopefully fixed in Perl 6
- There is already an open ticket (with a proposed solution) in PDF::API2 that I missed earlier.


In reply to Re: Error opening output from PDF::API2 by snoopy
in thread Error opening output from PDF::API2 by buckaduck

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.