pdflatex includegraphics eats newline of stream
Hi! pdftex is eating the last new-lines in streams included with includegraphics, when the stream has an extra new-line. Toy example; an object in the PDF image looks like this: 15 0 obj <>stream ABCDF endstream endobj [there are just new-lines at the end of ABCDF and in the next line]. When I include this PDF with includegraphics, the last new-line disappears, but the stream Length count does not get updated (or touched at all, as far as I can tell): 15 0 obj <>stream ABCDF endstream endobj This produces an error when trying to get PDF/A compliance, which is strict about stream lengths. Best, Florian
Hi Peter and Karl, I think I found the reason: In [pdftexdir/pdftoepdf.cc, line 603], a stream is written, and pdf_newline() is called after it: } else if (obj->isStream()) { initDictFromDict(obj1, obj->streamGetDict()); pdf_puts("<<\n"); copyDict(&obj1); pdf_puts(">>\n"); pdf_puts("stream\n"); copyStream(obj->getStream()->getUndecodedStream()); pdf_newline(); pdf_puts("endstream"); // can't simply write pdfendstream() However, this pdf_newline is optional [pdftexdir/utils.c, line 161]: void pdf_newline(void) { if (pdflastbyte != '\n') pdf_puts("\n"); } The new line should be always written using pdf_puts("\n") instead of pdf_newline() to have a correct stream length. Best, Florian
On 8 January 2014 21:12, Florian Breitwieser
Hi Peter and Karl, I think I found the reason:
In [pdftexdir/pdftoepdf.cc, line 603], a stream is written, and pdf_newline() is called after it: } else if (obj->isStream()) { initDictFromDict(obj1, obj->streamGetDict()); pdf_puts("<<\n"); copyDict(&obj1); pdf_puts(">>\n"); pdf_puts("stream\n"); copyStream(obj->getStream()->getUndecodedStream()); pdf_newline(); pdf_puts("endstream"); // can't simply write pdfendstream()
However, this pdf_newline is optional [pdftexdir/utils.c, line 161]: void pdf_newline(void) { if (pdflastbyte != '\n') pdf_puts("\n"); }
The new line should be always written using pdf_puts("\n") instead of pdf_newline() to have a correct stream length.
yes indeed, many thanks for your effort. Please feel free to commit the change to texlive svn if you would like, would be much appreciated. Regards, Thanh
Dear Thanh,
yes indeed, many thanks for your effort. Please feel free to commit the change to texlive svn if you would like, would be much appreciated.
Thank you (you and all TeX people) much more. I am happy if I can contribute, and submitted a request for a texlive svn account. Best regards, Florian
participants (3)
-
Florian Breitwieser
-
Peter Breitenlohner
-
The Thanh Han