ststeiger / PdfSharpCore

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

Trailer: ID is not space-separated. #442

Closed RenderMichael closed 4 months ago

RenderMichael commented 6 months ago

Reproduction:

public static string GenerateNewPdf()
{
    string path = $"outputs/Generated--{NewGuid():N}.pdf";
    using var document = new PdfDocument();
    PdfPage page = document.AddPage();
    document.Save(path);
    return Path.GetFullPath(path);
}

Outputs:

The trailer contains the line:

/ID[<FCEAE9E3BEA9864C83AA492B76687F02><FCEAE9E3BEA9864C83AA492B76687F02>]

There should be a space inserted.

Full file output ``` %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 ```
RenderMichael commented 6 months ago

I cloned the repo to try and debug through it, and found out this only happens in Release mode.