Skip Menu |

This queue is for tickets about the CAM-PDF CPAN distribution.

Report information
The Basics
Id: 76514
Status: resolved
Priority: 0/
Queue: CAM-PDF

People
Owner: Nobody in particular
Requestors: futuramedium [...] yandex.ru
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Saving (modifying) PDF with only one xref table produces corrupt file.
Suppose we have PDF with only one xref table -- i.e. file is not linearised and was not incrementally saved before. Examaple is attached. 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) is corrupt. xref table, added by CAM-PDF, is as follows: xref 0 12 0000000000 65535 f 0000000002 00001 f 0000000003 00001 f 0000000004 00001 f 0000000006 00001 f 0000002796 00001 n 0000000007 00001 f 0000000008 00001 f 0000000009 00001 f 0000000010 00001 f 0000000011 00001 f 0000000000 00001 f ALL objects (not one) are included and all are marked as free! That is certainly wrong. As a quick and dirty fix, which works for me, one line in procedure save can be changed from: if (!$self->{trailer}->{Prev}) to: if (!$self->{startxref}) Though it requires more thought and testing. Also, fix from my big-report 76513 should be applied to save modified file as expected. Best regards, Vadim
Subject: in.pdf
Download in.pdf
application/pdf 2.7k

Message body not shown because it is not plain text.

Subject: out.pdf
Download out.pdf
application/pdf 3.3k

Message body not shown because it is not plain text.

Good catch. I'm amazed that this didn't get reported 5 years ago. I guess that says that most users use $pdf->clean() or $pdf->cleanoutput() This fix will be in 1.58.