Skip Menu |

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

Report information
The Basics
Id: 103863
Status: open
Priority: 0/
Queue: CAM-PDF

People
Owner: Nobody in particular
Requestors: denis.rouzaud [...] gmail.com
Cc:
AdminCc:

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



Subject: CAM::PDF This stream is too complex for me to write
Date: Tue, 21 Apr 2015 20:32:15 +0200
To: bug-CAM-PDF [...] rt.cpan.org
From: Rouzaud Denis <denis.rouzaud [...] gmail.com>
Dear dev, I am facing a problem in CAM::PDF, ending up in a "TODO" part of the code. I am using CAM::PDF to find and replace text in a PDF file (don't tell me it's stupid, I know....). Anyway, while writing to output document I reach "This stream is too complex for me to write". Looking at the code, there is a “TODO” at this place. Would it be possible to write the missing part? If needed, we can sponsor this development. If needed please find a demo document with a minimal script to reproduce the error. Please let me know your thoughts, Best wishes, Denis

Message body not shown because it is not plain text.

Message body is not shown because sender requested not to inline it.

From: futuramedium [...] yandex.ru
I found this happens if file has xref as cross-reference stream (i.e. is 1.5-compatible), and we are trying to 'output' (as opposed to 'cleanoutput') it. The solution could be to insert a line just before 'return' of the '_buildxref' method: delete @{ $trailer }{ qw/ Length Filter DecodeParms Type Index W StreamData / }; Plus, the object of 'XRef' type is no longer needed and could be deleted, though its presence seems harmless. It survives after 'clean' (and thus 'cleanoutput'), but maybe gets destroyed during 'cleanse', I didn't check.
From: futuramedium [...] yandex.ru
An update to what I said above. The object of 'XRef' type should not, of course, be deleted, sorry. Moreover, if PDF file with x-ref stream is incrementally updated, and we try to append xref section with 'classic' xref table, then, it seems, some applications (including Adobe Reader) refuse to open it, though such situation is not prohibited by the Reference, I think. So it's necessary to append a section with x-ref stream -- which CAM::PDF can't output. I made some changes to parts of it, for my purposes (very large files, small updates using CAM::PDF) to work from disk (i.e. no file slurping) and also to append an update with either xref table or xref stream, depending on original file. Now the plan is to improve the solution to be more universal rather than just a hack for specific task :)