Hi, Monks.

I have a problem when merging PDF documents. I need to import first page from many one page PDF documents into one result PDF.

I try PDF::API2, PDF::Reuse, CAM::PDF but nothing helps :-(. My main problem is importing barcode from source PDF (see example 1 33 kb, example 2 33 kb). My program got this pdfs from USPS site and i need to create single PDF from them.

PDF::API2 and CAM::PDF don't show barcode at all. PDF::Reuse show barcode only on first page :-( (see PDF::API2 result 53 kb, CAM::PDF result 54 kb, PDF::Reuse result 65 kb).

Here my code.

For PDF::API2:

use PDF::API2; my $result_pdf = PDF::API2->new(); my $pdf = PDF::API2->open('label1.pdf'); my $page = $result_pdf->importpage($pdf, 1); $pdf = PDF::API2->open('label3.pdf'); $page = $result_pdf->importpage($pdf, 1); $result_pdf->saveas("pdfapi2_result.pdf");

For CAM::PDF:

use CAM::PDF; my $doc1 = CAM::PDF->new('label1.pdf') || die "$CAM::PDF::errstr\n"; my $doc2 = CAM::PDF->new('label3.pdf') || die "$CAM::PDF::errstr\n"; $doc1->appendPDF($doc2); $doc1->clearAnnotations(); $doc1->cleanoutput('campdf_result.pdf');

And for PDF::Reuse which works but only for first page:

use PDF::Reuse; prFile('new.pdf'); prDoc( { file => 'label3.pdf', first => 1, last => 1 }); prDoc( { file => 'label1.pdf', first => 1, last => 1 }); prEnd();

Could you explain why barcodes did't copy? What i must to do to copy them?

P.S. When i wrote this message i think about Javascript in the PDF. Maybe barcodes are creating by Javascript? And when i importing page from source file i'm importing Javascript but maybe this Javascript only generates barcode for the first page?


In reply to Problem importing page from PDF by Gangabass

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.