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

Cannot insert image. #434

Open IngoManthey opened 3 months ago

IngoManthey commented 3 months ago

In the previous versions I had no problems with the following code. ImageSource.ImageSourceImpl ??= new ImageSharpImageSource<Rgba32>(); header.AddImage(ImageSource.FromFile(Invoice.Image));

Now I get the following exception: System.MissingMethodException: Method not found: 'SixLabors.ImageSharp.Image1<!!0> SixLabors.ImageSharp.Image.Load(System.IO.Stream, SixLabors.ImageSharp.Formats.IImageFormat ByRef)'. at PdfSharpCore.Utils.ImageSharpImageSource1.FromStreamImpl(String name, Func1 imageStream, Nullable1 quality) at MigraDocCore.DocumentObjectModel.MigraDoc.DocumentObjectModel.Shapes.ImageSource.FromStream(String name, Func1 imageStream, Nullable1 quality) at PdfSharpCore.Drawing.XImage..ctor(Func1 stream) at PdfSharpCore.Drawing.XImage.FromStream(Func1 stream)

Can someone help me?

balkarov commented 3 months ago

I have the same problem. Any solution?

IngoManthey commented 3 months ago

Unfortunately I didn't get an answer. Keep waiting for a solution.

mtarlac commented 3 months ago

426

chrisg32 commented 3 months ago

@balkarov @IngoManthey Add package SixLabors.ImageSharp 2.1.7

balkarov commented 3 months ago

@chrisg32 I already use ImageSharp version 3.X

chrisg32 commented 3 months ago

@balkarov ImageSharp version 3.X is not supported with PdfSharpCore. You have to stick with 2.X for now. That is the problem.

IngoManthey commented 3 months ago

@chrisg32 I have

<PackageReference Include="SixLabors.ImageSharp" Version="2.1.7" />
<PackageReference Include="PdfSharpCore" Version="1.3.63" />

entered in the project. Unfortunately I still get the following erro [08:57:34 ERR] InvoiceController.GetPrintInvoice System.MissingMethodException: Method not found: 'SixLabors.ImageSharp.Image1<!!0> SixLabors.ImageSharp.Image.Load(System.String, SixLabors.ImageSharp.Formats. IImageFormat ByRef)'. at PdfSharpCore.Utils.ImageSharpImageSource1.FromFileImpl(String path, Nullable`1 quality)

chrisg32 commented 3 months ago

@IngoManthey That solution has work for me and a few others. Do you have any other projects in your solution that are referencing a higher version of image sharp?

I would suggest taking a look at the thread on #426 . @TonyValenti created a fork that adds support for the new image sharp. That could be an alternative for you until the package maintainers accept PR #427

IngoManthey commented 3 months ago

@chrisg32 I found the mistake. In my project I used the MudExRichTextEditor library. This uses version 3.1.3, which is why I installed 3.1.3. I would like to do without the library. Is there a way to use version?

chrisg32 commented 3 months ago

@IngoManthey If you want to use 3.1.3 then you will need to use the fork mentioned in #426 or wait for PR #427.