ststeiger / PdfSharpCore

Port of the PdfSharp library to .NET Core - largely removed GDI+ (only missing GetFontData - which can be replaced with freetype2)
Other
1.04k stars 231 forks source link

Ensure a space before PDF arrays are written, even in non-verbose mode #443

Closed RenderMichael closed 3 days ago

RenderMichael commented 1 month ago

Fixes #442

According to the spec, section 7.5.5, the trailer dictionary is shown to be space separated. Unfortunately that's not explicitly stated, so perhaps PDF parsers should be able to accept the following line:

/ID[<FCEAE9E3BEA9864C83AA492B76687F02><FCEAE9E3BEA9864C83AA492B76687F02>]

However, if we think that a space after /ID is good, then this PR fixes that.

Before:

Before ``` %PDF-1.4 %���� 1 0 obj << /CreationDate(D:20240522141508-04'00') /Creator /Producer(PDFsharp 1.50.4000-netstandard \(https://github.com/ststeiger/PdfSharpCore\)) >> endobj 2 0 obj << /Type/Catalog /Pages 3 0 R >> endobj 3 0 obj << /Type/Pages /Count 1 /Kids[4 0 R] >> endobj 4 0 obj << /Type/Page /MediaBox[0 0 612 792] /Parent 3 0 R /Group << /CS/DeviceRGB /S/Transparency >> >> endobj xref 0 5 0000000000 65535 f 0000000015 00000 n 0000000477 00000 n 0000000525 00000 n 0000000580 00000 n trailer << /ID[] /Info 1 0 R /Root 2 0 R /Size 5 >> startxref 692 %%EOF ```
After ``` %PDF-1.4 %���� 1 0 obj << /CreationDate (D:20240523110806-04'00') /Creator /Producer (PDFsharp 1.50.4000-netstandard \(https://github.com/ststeiger/PdfSharpCore\)) >> endobj 2 0 obj << /Type /Catalog /Pages 3 0 R >> endobj 3 0 obj << /Type /Pages /Count 1 /Kids [4 0 R] >> endobj 4 0 obj << /Type /Page /MediaBox [0 0 612 792] /Parent 3 0 R /Group << /CS /DeviceRGB /S /Transparency >> >> endobj xref 0 5 0000000000 65535 f 0000000015 00000 n 0000000480 00000 n 0000000529 00000 n 0000000586 00000 n trailer << /ID [<6751B1FD3ECE5F4FAA48B04D7CC83F7D><6751B1FD3ECE5F4FAA48B04D7CC83F7D>] /Info 1 0 R /Root 2 0 R /Size 5 >> startxref 702 %%EOF ```
ststeiger commented 3 days ago

Merged.