Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Feb 23, 2022 9:11 am

Hello,

I am using spire.pdf to generate a pdf document that currently uses system.drawing
However, the azure server supports .NET 5, so I did not pass the pipeline

System.TypeInitializationException : The type initializer for 'Application.Extensions.GeneratorPDF' threw an exception.
---- System.TypeInitializationException : The type initializer for 'Gdip' threw an exception.
-------- System.PlatformNotSupportedException : System.Drawing.Common is not supported on non-Windows platforms. See (microsoft webiste) for more information.


I have been looking for a solution but so far have not been able to find one. Is there any way out of this?
Thanks.

WalterWhite
 
Posts: 1
Joined: Wed Feb 23, 2022 9:00 am

Wed Feb 23, 2022 9:58 am

Hello,

Thanks for your inquiry!
We have noticed the issue you mentioned, two solutions for this issue are as follows:
1) Microsoft's solution tutorial: https://docs.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/6.0/system-drawing-common-windows-only
2) Solution for Spire.PDF: replace System.Drawing.Common with SkiaSharp
Please follow the next steps to use the NetStandard dlls which based on SkiaSharp to your project manually.
Please download Spire.PDF from our website, and manually add the DLLs from the folder “netstandard2.0” (see screenshot). In addition, you need to install the following dependencies via NuGet.

SkiaSharp (>= 1.68.0)
System.Text.Encoding.CodePages (>= 4.5.0)
System.Memory (>= 4.5.0)
System.Buffers (>= 4.5.0)
System.Runtime.CompilerServices.Unsafe (>= 4.5.0)

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1651
Joined: Wed Apr 07, 2021 2:50 am

Thu May 12, 2022 3:51 pm

Hello

I am using Spire.Pdf Free Edition 8.2.2.1360 + .net 6.0 to save pdf page into image
and I noticed that SaveAsImage return System.Drawing.Image, which is only support on windows

Is there any solution about this. tq

Code: Select all
   
    var pdf = new Spire.Pdf.PdfDocument();
    pdf.LoadFromBytes(pdfcontent);
    System.Drawing.Image img = pdf.SaveAsImage(pageindex);
    using( var stream = new System.IO.MemoryStream())
    {
        img.Save(stream, ImageFormat.Png);
        //'Image.Save(Stream, ImageFormat)' is only supported on: 'windows'.
    }

tomxu
 
Posts: 2
Joined: Sat Nov 15, 2014 9:58 am

Fri May 13, 2022 10:39 am

tomxu wrote:Hello

I am using Spire.Pdf Free Edition 8.2.2.1360 + .net 6.0 to save pdf page into image
and I noticed that SaveAsImage return System.Drawing.Image, which is only support on windows

Is there any solution about this. tq

Code: Select all
   
    var pdf = new Spire.Pdf.PdfDocument();
    pdf.LoadFromBytes(pdfcontent);
    System.Drawing.Image img = pdf.SaveAsImage(pageindex);
    using( var stream = new System.IO.MemoryStream())
    {
        img.Save(stream, ImageFormat.Png);
        //'Image.Save(Stream, ImageFormat)' is only supported on: 'windows'.
    }

Hi,

You can refer to the solution provided by Annika above. If there is other issue, just feel free to contact us.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Fri May 13, 2022 1:12 pm

Hello

Thank you for your reply.

I previously copy dll from .net6.0 folder, looks not working with non-windows platform.
so we must copy dll from “netstandard2.0”, but not all version have “netstandard2.0” folder.

now it works, Thanks again.

tomxu
 
Posts: 2
Joined: Sat Nov 15, 2014 9:58 am

Mon May 16, 2022 9:07 am

tomxu wrote:Hello

Thank you for your reply.

I previously copy dll from .net6.0 folder, looks not working with non-windows platform.
so we must copy dll from “netstandard2.0”, but not all version have “netstandard2.0” folder.

now it works, Thanks again.


You are welcome!
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Return to Spire.PDF