如何将PDF文件与Perl合并?

时间:2023-01-15 12:36:59

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

使用Perl,如何将示例PDF文件合并或合并为单个PDF文件?

3 个解决方案

#1


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:

CAM :: PDF可以很容易地做到这一点,并有一个简单的命令行前端来帮助。注意:我是该库的作者。例:

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

From the SYNOPSIS section of the perldoc:

从perldoc的SYNOPSIS部分:

my $anotherpdf = CAM::PDF->new('test2.pdf');
$pdf->appendPDF($anotherpdf);

#2


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

为什么你需要从Perl做到这一点?克里斯已经提到过CAM :: PDF。

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

如果你只需要合并它们,pdftk(PDF ToolKit)就可以了。这是一个简单的命令行:

pdftk file1.pdf file2.pdf cat output merged.pdf

#3


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.

您可以使用GhostScript实用程序pdf2ps将PDF转换为PostScript文件,连接PostScript文件,然后使用ps2pdf将结果转换回PDF。

#1


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:

CAM :: PDF可以很容易地做到这一点,并有一个简单的命令行前端来帮助。注意:我是该库的作者。例:

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

From the SYNOPSIS section of the perldoc:

从perldoc的SYNOPSIS部分:

my $anotherpdf = CAM::PDF->new('test2.pdf');
$pdf->appendPDF($anotherpdf);

#2


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

为什么你需要从Perl做到这一点?克里斯已经提到过CAM :: PDF。

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

如果你只需要合并它们,pdftk(PDF ToolKit)就可以了。这是一个简单的命令行:

pdftk file1.pdf file2.pdf cat output merged.pdf

#3


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.

您可以使用GhostScript实用程序pdf2ps将PDF转换为PostScript文件,连接PostScript文件,然后使用ps2pdf将结果转换回PDF。