0
是否有任何人有脚本合并使用PDF:API2的2个pdf文件?我只安装了这个perl模块,我的主机不允许我访问c编译器以进一步安装perl模块。使用PDF合并2 pdf文件:API2
是否有任何人有脚本合并使用PDF:API2的2个pdf文件?我只安装了这个perl模块,我的主机不允许我访问c编译器以进一步安装perl模块。使用PDF合并2 pdf文件:API2
这是一个单击质量脚本,告诉您如何使用PDF::API2
合并几个PDF文件。
#!/usr/bin/perl
use strict;
use warnings;
use PDF::API2;
# files to merge
my @input_files = (
'document1.pdf',
'document2.pdf',
'document3.pdf',
);
my $output_file = 'new.pdf';
# the output file
my $output_pdf = PDF::API2->new(-file => $output_file);
foreach my $input_file (@input_files) {
my $input_pdf = PDF::API2->open($input_file);
my @numpages = (1..$input_pdf->pages());
foreach my $numpage (@numpages) {
# add page number $numpage from $input_file to the end of
# the file $output_file
$output_pdf->importpage($input_pdf,$numpage,0);
}
}
$output_pdf->save();
你应该看看[faq#howtoask]。几乎所有以前的问题都不是很好。如果你需要帮助,请做些什么。 – simbabque
如果您对Perl模块的编译和安装C代码的访问权限有限,另一种选择是上传[pdftk]的编译版本(http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/ )来调用(如果你的主机允许的话)。与使用PDF :: API2相比,pdftk是多功能的,并且冗长。 – Stennie