Skip Menu |

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

Report information
The Basics
Id: 120450
Status: resolved
Priority: 0/
Queue: PDF-API2

People
Owner: Nobody in particular
Requestors: 'spro^^*%*^6ut# [...] &$%*c
Cc:
AdminCc:

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



Version 2.031. $ perl -MPDF::API2 -e 'PDF::API2->open("t/4pages.pdf")->saveas("pa.pdf")' Can't use an undefined value as an ARRAY reference at /Library/Perl/5.12/PDF/API2/Basic/PDF/File.pm line 1276. I was just trying to rewrite a file that another PDF module couldn’t read (to see if that would make it readable by the other module). The documentation implies that this should work. I encountered this problem with PDFs generated by Mac OS X 10.8.5 Quartz PDFContext and those generated by ABBYY FineReader. (I.e., it does not seem specific to any particular PDF generator.)
Sorry, I forgot the subject, but I don’t have permission to set it. It should be: ->open followed by ->saveas fails
This is a known issue with cross-reference streams, which are currently read-only in PDF::API2 (dup. of RT #117184).
On Tue May 23 22:19:37 2017, SSIMMS wrote: Show quoted text
> This is a known issue with cross-reference streams, which are > currently read-only in PDF::API2 (dup. of RT #117184).
The PDF I tested with is a 1.3 file, here attached. It seems to be the combination of ‘open’ followed immediately by ‘saveas’ that does not work. If it is not designed to work that way, would you consider improving the documentation?
Subject: 4pages.pdf
Download 4pages.pdf
application/pdf 8.3k

Message body not shown because it is not plain text.

Subject: [PATCH] for ->saveas not working
RT-Send-CC: steve [...] deefs.net
On Wed May 24 17:55:38 2017, SPROUT wrote: Show quoted text
> On Tue May 23 22:19:37 2017, SSIMMS wrote:
> > This is a known issue with cross-reference streams, which are > > currently read-only in PDF::API2 (dup. of RT #117184).
> > The PDF I tested with is a 1.3 file, here attached. > > It seems to be the combination of ‘open’ followed immediately by > ‘saveas’ that does not work. If it is not designed to work that way, > would you consider improving the documentation?
This patch seems to solve the problem.
Subject: open_QMs6IgBI.txt
--- a/lib/PDF/API2/Basic/PDF/File.pm 2017-01-26 10:30:03.000000000 -0800 +++ b/lib/PDF/API2/Basic/PDF/File.pm 2017-06-21 16:33:17.000000000 -0700 @@ -1273,7 +1273,7 @@ my $tloc = $fh->tell(); $fh->print("xref\n"); - my @xreflist = sort { $self->{' objects'}{$a->uid}[0] <=> $self->{' objects'}{$b->uid}[0] } (@{$self->{' printed'}}, @{$self->{' free'}}); + my @xreflist = sort { $self->{' objects'}{$a->uid}[0] <=> $self->{' objects'}{$b->uid}[0] } (@{$self->{' printed'}||[]}, @{$self->{' free'}||[]}); my ($i, $j, $k); unless ($update) { @@ -1294,7 +1294,7 @@ } } - my @freelist = sort { $self->{' objects'}{$a->uid}[0] <=> $self->{' objects'}{$b->uid}[0] } @{$self->{' free'}}; + my @freelist = sort { $self->{' objects'}{$a->uid}[0] <=> $self->{' objects'}{$b->uid}[0] } @{$self->{' free'}||[]}; $j = 0; my $first = -1; $k = 0; for ($i = 0; $i <= $#xreflist + 1; $i++) {
Aha, you're right. Thanks for the patch. I've implemented it and added a test case. On Wed Jun 21 19:37:23 2017, SPROUT wrote: Show quoted text
> On Wed May 24 17:55:38 2017, SPROUT wrote:
> > On Tue May 23 22:19:37 2017, SSIMMS wrote:
> > > This is a known issue with cross-reference streams, which are > > > currently read-only in PDF::API2 (dup. of RT #117184).
> > > > The PDF I tested with is a 1.3 file, here attached. > > > > It seems to be the combination of ‘open’ followed immediately by > > ‘saveas’ that does not work. If it is not designed to work that way, > > would you consider improving the documentation?
> > This patch seems to solve the problem.