.Net 7 and Docker (System.Drawing deprecated on non-Windows)

After migrating to .Net 7, the application doesn’t work on Docker because of the dependency to System.Drawing.

using MemoryStream ms = new MemoryStream();
doc.Pages.FirstEx().SendTo(new PngDevice(new Resolution(100)), ms);
ms.Seek(0, SeekOrigin.Begin);
PlatformNotSupportedException: System.Drawing.Common is not supported on this platform.

 at System.Drawing.Drawing2D.Matrix..ctor(Single m11, Single m12, Single m21, Single m22, Single dx, Single dy)
   at #=z7JhFaSUoljpoMpgPGnZHGARdceTnqH1i1A==.#=zcO5wkTo=(Single #=zEa5Qlc8=, Single #=ziVvwtA4=, Single #=zdrkDA3A=, Single #=z3jl8Ogk=, Single #=ze_J3uh8=, Single #=zM0hRpVA=, #=zZziYqioG5Y7d$TVx8KWQ2G3u5X9y0$ShCw== #=zDl$RHio=)
   at #=zTqXlOYlaxvwI3cvKbLLdxL24$T$TdTXnZdOfY7Q1N2Am.#=zvEShUlXQKr45(#=zw34YIMWWW$i4N0k7rtWKKQDzFW7uyTCAPA== #=zipLwPQ0=, #=zEgoqmgJlaAYLJwQeA58Fr41EPP4RkL6HRgnbLLg= #=zzS78m03K7NoA, #=zhLm6G76SAPmgChnFKfoKonvTrtDWiPuC5A== #=zQSM6H4w=, Single #=z_ejd7OSA2I3i, Single #=zwT2fYmJq0_TT, Boolean #=zTyX7SA7vKtjJhUEMnw==, Int32 #=zkRIEc3ETtZRgpQCByJ$S3zs=, Boolean #=z5KZAFB4b0ctw, Double& #=zlhFB2zc=, Double& #=zmPZiGts=, #=zEgoqmgJlaAYLJwQeA58Fr8JvLPHIgdCQwQ==& #=zOdlJIgA=)
   at #=zTqXlOYlaxvwI3cvKbLLdxL24$T$TdTXnZdOfY7Q1N2Am..ctor(#=zRGmXEZ1amxDWPUqvzds5XUa1E33q #=zXGVj7e4=, #=zw34YIMWWW$i4N0k7rtWKKQDzFW7uyTCAPA== #=zipLwPQ0=, #=zEgoqmgJlaAYLJwQeA58Fr41EPP4RkL6HRgnbLLg= #=zzS78m03K7NoA)
   at #=zPS_QfQwEHyKSONvtk$Y9iW8QKaRwdHpzBuEKxaM=.#=z4acuYWcR8E6K(#=zRGmXEZ1amxDWPUqvzds5XUa1E33q #=zXGVj7e4=, #=zw34YIMWWW$i4N0k7rtWKKQDzFW7uyTCAPA== #=zipLwPQ0=, #=zEgoqmgJlaAYLJwQeA58Fr41EPP4RkL6HRgnbLLg= #=zzS78m03K7NoA)
   at #=zSc2zND9faB2l1cyMlh71roe82escM1Qx7rvrVZkkviVa.#=zlGTNJbg=(#=zRGmXEZ1amxDWPUqvzds5XUa1E33q #=zXGVj7e4=, #=zw34YIMWWW$i4N0k7rtWKKQDzFW7uyTCAPA== #=zipLwPQ0=, #=zEgoqmgJlaAYLJwQeA58Fr41EPP4RkL6HRgnbLLg= #=z13gOXjw=, #=zTqXlOYlaxvwI3cvKbLLdxL24$T$TdTXnZdOfY7Q1N2Am& #=ztjG86Q0=)
   at #=zE18SMiXycCnPZQgFlQ6WFuPKdvUJ.#=zxjMisnU=(#=zTqXlOYlaxvwI3cvKbLLdxL24$T$TdTXnZdOfY7Q1N2Am& #=ztjG86Q0=)
   at Aspose.Pdf.Devices.ImageDevice.#=zxjMisnU=(Page #=zipLwPQ0=)
   at Aspose.Pdf.Devices.PngDevice.Process(Page page, Stream output)

The previous flag that allowed the compatibility using “System.Drawing.EnableUnixSupport”: true and libgdiplus is gone.

Looks like some important rewrites are going to be needed in Aspose.PDF to make it work.

Any estimation on when a .Net 7 + Docker compatible version could come?

2 Likes

@swen.kusel

We will surely investigate the compatibility of Aspose.PDF for .NET under .NET 7 from perspective of System.Drawing dependency in it. A ticket as PDFNET-53092 has been logged in our issue tracking system for the sake of further investigation and analysis. We will look into its details and keep you posted with its rectification status. Please be patient and spare us some time.

We are sorry for the inconvenience.

This needs to be prioritized as we have now fully upgraded to .NET 7 and this product is not compatible.

@nvanh

Your concerns and issue severity has been updated and information of the ticket has been revised. We will let you know as soon as we some progress in this regard. We apologize for the inconvenience.

We are using this product in a live system, and it is also broken for .net7. I don’t see any updates relating to any fix or workaround. If this is correct, can this be escalated?

@asad.ali This is blocking us upgrading to dotnet 7 which we need ASAP.
The piece of code that is not working is

var tickStream = Assembly.GetExecutingAssembly()
                    .GetManifestResourceStream($"Tick.png");

form.Resources.Images.Add(tickStream);

Basically at this point it fails to use System.Drawing which works in dotnet 7 for Windows but not for Linux. If there is another way to add an image to the resources that does not use this package?

@amosJ
@swen.kusel
@Samuel_Garratt
@nvanh

Aspose.PDF.Drawing NuGet package was released, DLL in this package doesn’t have System.Drawing.Common dependency.

You only need to install Aspose.PDF.Drawing instead of Aspose.PDF. Aspsoe.PDF with Drawing contains Aspose.Drawing inside, installing neither System.Drawing nor Aspose.Drawing is required.

This assembly correctly works under Linux environment. It will be published as separated assembly until we sure that this works absolutely perfect and may replace current System.Drawing-based assembly by 100%. When we ensure that, we will replace System.Drawing version with Aspose.Drawing one.

1 Like

Thank you @asad.ali. We just tried Aspose.PDF.Drawing (needed Aspose.Drawing as well) and it all worked fine in docker dotnet 7 in linux. Thank you

@Samuel_Garratt

Thanks for your kind feedback. Please feel free to create a new topic in case you face any issues.

Running in Windows using Aspose.PDF each page.SendTo(new PngDevice(new Resolution(100)), ms); takes 600-700ms

image1.png (4.2 KB)

While using Aspose.PDF it takes 4-6 seconds! almost 10x slower
image2.png (3.3 KB)

I will complete the benchmark with Docker performace soon.

In Production Server, converting to Aspose.PDF.Drawing in the Docker image works, but takes about 5s per image. 15 seconds in total!

image3.png (3.5 KB)

Sending the PDF to a Windows machine, converting there, and getting all the images back in full resolution takes about 3 seconds for the 3 pages:

  • About 0.7 seconds per image x 2 = 2s in total
  • About 1s for transfer I suppose

image4.png (6.3 KB)

What are the reasons for this degradation? I know GDI is fast, but… 10 times faster?

Unfortunately, the performance is so poor that I will have to stick with the workaround of delegating this work to a Windows machine.

Please inform me if there are important performance improvements to reconsider this decision.

@swen.kusel

We have noticed your comments and feedback. We will surely perform analysis against them. However, can you please share a sample PDF with which you have tested and observed these performance issues? We will log an investigation ticket in our issue tracking system and share the ID with you.

The problem happens with almost any PDF that contains scanend images, but contains personal information. How can I safely upload it?

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-53612

You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@swen.kusel

You can also share the file using private message option. image.png (10.5 KB)