#!perl -w
use strict;
use CAM::PDF;
my $infile = shift || die 'syntax...';
my $outfile = shift || die 'syntax...';
my $pdf = CAM::PDF->new($infile) || die;
my $info = $pdf->getValue($pdf->{trailer}->{Info});
if ($info) {
#use Data::Dumper; print Dumper($info);
my $title = $info->{Title};
if ($title) {
$title->{value} = 'Foo';
# for a proper implementation, we should mark the holder of $info as dirty...
# But cleanoutput ignores dirty flags anyway and writes the whole doc
$pdf->cleanoutput($outfile);
}
}
I'm the author of CAM::PDF. The library doesn't support this sort of edit, but you can do it by digging into the internals like this:
#!perl -w
use strict;
use CAM::PDF;
my $infile = shift || die 'syntax...';
my $outfile = shift || die 'syntax...';
my $pdf = CAM::PDF->new($infile) || die;
my $info = $pdf->getValue($pdf->{trailer}->{Info});
if ($info) {
#use Data::Dumper; print Dumper($info);
my $title = $info->{Title};
if ($title) {
$title->{value} = 'Foo';
# for a proper implementation, we should mark the holder of $info as dirty...
# But cleanoutput ignores dirty flags anyway and writes the whole doc
$pdf->cleanoutput($outfile);
}
}
发布评论
评论(1)
我是 CAM::PDF 的作者。该库不支持这种编辑,但您可以通过深入了解内部结构来完成此操作,如下所示:
I'm the author of CAM::PDF. The library doesn't support this sort of edit, but you can do it by digging into the internals like this: