Skip to content

PDFSharp and HtmlRenderer.PdfSharp 1.5.2: PNG Compatibility Problem #241

@thiagosdrv

Description

@thiagosdrv

I use PDFSharp 6.2.4 for manual PDF generation and HtmlRenderer.PdfSharp for HTML-to-PDF conversion.
Up to version 1.5.0.6 of HtmlRenderer.PdfSharp, there were no compatibility issues with PDFSharp.

However, in the current version 1.5.2 of HtmlRenderer.PdfSharp, dependencies on the System.Formats.Nrbf and System.Resources.Extensions libraries were introduced.

After installing the System.Formats.Nrbf version 10.0.8 or System.Resources.Extensions version 10.0.8 libraries, an "Unsupported image format" exception occurs when using the PdfSharp.Drawing.XImage.FromFile("PNG_File_Folder") method or the XImage.FromStream method in PDFSharp version 6.2.4.

The PNG file is processed correctly when these dependencies are not present.
Without System.Formats.Nrbf and System.Resources.Extensions, adding the image to the PDF works as expected.
However, after installing these libraries, the call to PdfSharp.Drawing.XImage.FromFile("PNG_File_Folder") starts failing with the error "Unsupported image format".

This is a small image, an icon of approximately 1 KB. I also tested converting the image to both 8-bit and 16-bit formats; however, unfortunately, the issue still persists.

I will also contact the PDFSharp team to report the issue.
However, they requested a sample project that reproduces the problem in order to facilitate further investigation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions