如何使用 CAM::PDF::Annot(perl 模块)而不会出错? [英] How do I use CAM::PDF::Annot (perl module) without erroring?
问题描述
我一直在尝试将 CAM:PDF::Annot 用于最基本的目的,聚合两个 pdf 的注释,但没有取得任何成功.
I have been trying to use CAM:PDF::Annot for it's most basic purpose, aggregating the annotations of two pdf's, but have not had any success.
我一直在尝试在 CPAN 上模拟软件包概要中的内容,但一直出现错误.
I have been trying to emulate what is in the package's synopsis on CPAN, but keep coming up with an error.
CPAN 概要中的代码(作为完整的脚本)或任何建议都会有所帮助.
The code in the CPAN synopsis (as a completed script), or any advice would be helpful.
CPAN 页面:http://metacpan.org/pod/CAM::PDF::注释
到目前为止我有:
#!/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()
方法采用注释对象而不是数组引用.尝试按照文档说明进行操作:
Well, the getAnnotations()
method appears to return an array reference, whereas the appendAnnotation()
method takes an annotation object and not an array reference. Try doing what the documetation says:
for my $annotRef ( @{$pdf->getAnnotations( $page )} ) {
$otherDoc->appendAnnotation( $page, $pdf, $annotRef, \%refs );
}
您没有遍历从 getAnnotations()
返回的所有注释引用,您只是试图将完整的数组引用粘贴在那里,这是行不通的.
You're not looping over all of the annotation references that you get back from getAnnotations()
, you're just trying to stick the full array reference in there, and that's not going to work.
这篇关于如何使用 CAM::PDF::Annot(perl 模块)而不会出错?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!