How can I merge PDF files with Perl?

前端 未结 3 366
予麋鹿
予麋鹿 2021-01-17 22:58

Using Perl, how can I combine or merge the sample PDF files into a single PDF file?

相关标签:
3条回答
  • 2021-01-17 23:34

    You can use the GhostScript utility pdf2ps to convert the PDFs into PostScript files, concatenate the PostScript files, and then use ps2pdf to convert the result back into a PDF.

    0 讨论(0)
  • 2021-01-17 23:39

    Why do you need to do it from Perl? Chris has already mentioned CAM::PDF.

    If you just need to merge them, pdftk (PDF ToolKit) works just fine. It's a simple command line:

    pdftk file1.pdf file2.pdf cat output merged.pdf
    
    0 讨论(0)
  • 2021-01-17 23:51

    CAM::PDF can do this quite easily, and has a simple command-line front end to help. Note: I'm the author of that library. Example:

    appendpdf.pl file1.pdf file2.pdf outfile.pdf
    

    From the SYNOPSIS section of the perldoc:

    my $anotherpdf = CAM::PDF->new('test2.pdf');
    $pdf->appendPDF($anotherpdf);
    
    0 讨论(0)
提交回复
热议问题