empira / PDFsharp-1.5

A .NET library for processing PDF
MIT License
1.28k stars 589 forks source link

Unable to add gdi image loded from jpeg using FromGdiPlusImage #146

Closed DarkOoze closed 1 year ago

DarkOoze commented 3 years ago

Expected Behavior

Image added to page or an exception if it is not possible.

Actual Behavior

Image is added to the pdf but the stream length is 0.

Steps to Reproduce the Behavior

Create a Gdi Image from a file using Image.FromFile(string fileName) Add image to pdf using XImage.FromGdiPlusImage

Test project: pdfsharp-image-issue.zip

crypto-rsa commented 3 years ago

I have a similar issue. Using MigraDoc, I create a table which contains an image in one of the cells. When exported to RTF, the image visible. When exported to PDF (through PDFsharp), it is not visible although its size is being accounted for in the layout.

ThomasHoevel commented 3 years ago

I have a similar issue. Using MigraDoc, I create a table which contains an image in one of the cells. When exported to RTF, the image visible. When exported to PDF (through PDFsharp), it is not visible although its size is being accounted for in the layout.

Rather sounds like an unrelated issue.

ThomasHoevel commented 3 years ago

Create a Gdi Image from a file using Image.FromFile(string fileName) Add image to pdf using XImage.FromGdiPlusImage

The .FromGdiPlusImage has its limitations and should not be used when you have a filename that allows you to call XImage.FromFile directly.