TTMSFNCPDFCore.SaveToStream, file does not open in chrome acrobat extension

When adding/changing a title/author to a pdf and then save the pdf with SaveDocument(const FileStream: TStream) works for most pdf viewers. There is an issue for the chrome adobe acrobat extension. This extension will not open the file.

Not much wrong with the file but there is an issue with the xref, the extension probably recognizes 21 bytes instead of 20 due to the CRLF

Working pdf:

And a pdf after this is saved with the pdflib

Removing the CR from the xref solves the issue of the file not opening in the chrome adobe acrobat extension.

I think that the issue can be solved by removing #13 in procedure TTMSFNCPDFCore.SaveToStream(const AStream: TStream)

XRefOffset := AStream.Position;
WriteRaw(AStream, RawByteString('xref'#10'0 ' + IntToStr(MaxNumber + 1) + #10));
WriteRaw(AStream, '0000000000 65535 f '#13#10);
for I := 1 to MaxNumber do
if Active[I] then
WriteRaw(AStream, RawByteString(Format('%.10d 00000 n '#13#10,
[Offsets[I]])))
else
WriteRaw(AStream, '0000000000 00000 f '#13#10);

Hi Erwin,

Thank you for the clear analysis. You are right: every cross-reference entry in a PDF must be exactly 20 bytes, and SaveToStream wrote 21 (a space followed by CR LF). Most viewers tolerate that; the Acrobat extension does not.

The entries now end with a space and a line feed, so each is exactly 20 bytes. We verified this on a document whose title and author were changed and then saved. The fix will be included in the next TMS FNC Core update. The local change you made (removing the #13) is the same fix, so you can keep it until then.