empira / PDFsharp

PDFsharp and MigraDoc Foundation for .NET 6 and .NET Framework
https://docs.pdfsharp.net/
Other
398 stars 91 forks source link

incorrect image path concatenation under Linux #121

Open pamapa opened 1 month ago

pamapa commented 1 month ago

If you think there is a bug in PDFsharp then please use the IssueSubmissionTemplate to make the issue replicable.
https://docs.pdfsharp.net/General/IssueReporting.html

Image.cs uses path + "\\", which can not work under Linux: https://github.com/empira/PDFsharp/blob/fd6d603d81ab42a3fab508fc65d56322b4ff2760/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Shapes/Image.cs#L169

-> leads to ImageNotFound under Linux...

When looking through the source code I have seen an other location that needs a fix: PathHelper.cs: https://github.com/empira/PDFsharp/blob/fd6d603d81ab42a3fab508fc65d56322b4ff2760/src/foundation/src/shared/src/PdfSharp.Quality/PathHelper.cs#L28

Thanks.

Resources

The official project web site:
https://docs.pdfsharp.net/

The official peer-to-peer support forum:
http://forum.pdfsharp.net/

Reporting an Issue Here

Expected Behavior

When we execute our code under Windows it works as expected, when doing the same under Linux, we get "Image not found". We have double checked the image path on our side...

Actual Behavior

Renders actual Image under Windows and Linux.

We are using as workaround absolute paths for now:

string imageFile = Path.Combine(Environment.CurrentDirectory, "Path1/Path2/image.png");
var image = header.AddImage(imageFile);

Steps to Reproduce the Behavior

We strongly recommend using the IssueSubmissionTemplate to make sure we can replicate the issue.
https://docs.pdfsharp.net/General/IssueReporting.html