Subject: | When saving, generation number of object is incremented, though it shouldn't. |
Hi,
Suppose we run simple program on attached in_.pdf:
use warnings;
use strict;
use CAM::PDF;
my $doc = CAM::PDF->new('in_.pdf');
my $p = $doc->getPageContent(1);
$doc->setPageContent(1, $p);
$doc->output('out_.pdf');
Actually, in this example we just modify one object. Modified PDF
(out_.pdf) opens as blank page in Adobe Reader. In case of real files
and real programs, when several objects are modified, Reader might
report error opening file. Other viewers might demonstrate different
behaviour.
In xref table, added by CAM-PDF, we find
12 1
0000004096 00001 n
I.e. generation number was increased. According to PDF specification, GN
of modified object should remain the same. Only if object is deleted,
and later we re-use object number from free list, GN is incremented.
If we change GN (1 byte in out_.pdf) to 0, file opens as expected.
Problem could be solved modifying one line in procedure save, from:
$self->{versions}->{$key}++;
to:
if ($self->{versions}->{$key}==-1) {$self->{versions}->{$key}++};
though it requires further tests. It works with my files and my
scenarios of CAM-PDF usage.
As a side note, this problem seems always to have existed. No-one ever
uses "output"? Only "cleanoutput"? Strange...
Best regards,
Vadim
Subject: | out_.pdf |
Message body not shown because it is not plain text.
Subject: | in_.pdf |
Message body not shown because it is not plain text.