如何使用CAM::PDF::Annot(perl模块)而不出错?
我一直在尝试使用CAM:PDF::Annot作为最基本的用途,将两个PDF的注释聚合在一起,但没有取得任何成功 我一直在尝试模仿CPAN的软件包概要中的内容,但不断出现错误 CPAN概要中的代码(作为完整的脚本)或任何建议都会有所帮助 CPAN页面: 到目前为止,我已经:如何使用CAM::PDF::Annot(perl模块)而不出错?,perl,pdf,hash,annotations,Perl,Pdf,Hash,Annotations,我一直在尝试使用CAM:PDF::Annot作为最基本的用途,将两个PDF的注释聚合在一起,但没有取得任何成功 我一直在尝试模仿CPAN的软件包概要中的内容,但不断出现错误 CPAN概要中的代码(作为完整的脚本)或任何建议都会有所帮助 CPAN页面: 到目前为止,我已经: #!/usr/bin/perl use strict use CAM::PDF; use CAM::PDF::Annot; sub main() { my $pdf = CAM::PDF::Annot->new(
#!/usr/bin/perl
use strict
use CAM::PDF;
use CAM::PDF::Annot;
sub main()
{
my $pdf = CAM::PDF::Annot->new( 'testAnnotPDF.pdf' );
my $otherDoc = CAM::PDF::Annot->new( 'testAnnotPDF2.pdf' );
my $page = 1;
my %refs;
my $hrefs = \%refs;
for my $annotRef (@{$pdf->getAnnotations($page)}){
$otherDoc->appendAnnotation( $page, $pdf, $annotRef, $hrefs );
}
$otherDoc->output('pdf_merged.pdf');
}
exit main;
好的,
getAnnotations()
方法似乎返回数组引用,而appendAnnotation()
方法接受注释对象而不是数组引用。试着按照文件上说的做:
for my $annotRef ( @{$pdf->getAnnotations( $page )} ) {
$otherDoc->appendAnnotation( $page, $pdf, $annotRef, \%refs );
}
您没有遍历从
getAnnotations()
返回的所有注释引用,您只是试图将完整数组引用粘贴在其中,这是行不通的。您编写了哪些代码引发此错误?