我如何使用CAM :: PDF ::阿诺(Perl模块)无示数? [英] How do I use CAM::PDF::Annot (perl module) without erroring?

查看:201
本文介绍了我如何使用CAM :: PDF ::阿诺(Perl模块)无示数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用CAM:PDF ::阿诺为它的最基本的目的,聚集的两个PDF的注释,但都没有成功。

我一直在试图效仿的是在包对CPAN故事大纲,但保留未来与一个错误。

在CPAN剧情简介code(作为一个完整的脚本),或者任何意见将是有益的。

CPAN页: http://metacpan.org/pod/CAM :: PDF ::阿诺

到目前为止,我有:

 #!的/ usr / bin中/ perl的
使用严格
使用CAM :: PDF;
使用CAM :: PDF ::阿诺;子的main()
{
   我的$ = PDF :: CAM PDF :: Annot->新建('testAnnotPDF.pdf');
   我的$ otherDoc = CAM :: PDF :: Annot->新建('testAnnotPDF2.pdf');
   我的$页面= 1;
   我的裁判%;
   我的$的HREF = \\%裁判;
   我的$ annotRef(@ {$ PDF-> getAnnotations($页)}){
       $ otherDoc-> appendAnnotation($页,$ PDF,$ annotRef,$的HREF);
   }
   $ otherDoc->输出(pdf_merged.pdf');
}
退出为主;


解决方案

那么, getAnnotations()方法自然会返回数组引用,而 appendAnnotation()方法接受一个注释对象,而不是一个数组引用。尝试做documetation这样说:

 我的$ annotRef(@ {$ PDF-> getAnnotations($页)}){
  $ otherDoc-> appendAnnotation($页,$ PDF,$ annotRef,\\%裁判);
}

您不是遍历所有的注释引用您从 getAnnotations取回()的,你只是想在那里坚持全数组引用,而这行不通的。

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.

I have been trying to emulate what is in the package's synopsis on CPAN, but keep coming up with an error.

The code in the CPAN synopsis (as a completed script), or any advice would be helpful.

CPAN page: http://metacpan.org/pod/CAM::PDF::Annot

So far I have:

#!/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;

解决方案

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 );
}

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 ::阿诺(Perl模块)无示数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆