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 Jan 18, 2023 2:54 am

Hi,
I’m testing the free version for a Maui project on Windows and MacOS.

On Windows the ‘save as PNG’ is just working fine.
On the Mac I get the following exception:
The type initializer for 'spr⥪' threw an exception.


Any clue?
Regards,
Michael

MichaelE
 
Posts: 2
Joined: Wed Jan 18, 2023 2:49 am

Wed Jan 18, 2023 3:58 am

Hello,

Thanks for your inquiry.
I suggest you can use the latest commercial version of Spire.Pdf to test again your scenario, due to the latest commercial version is more stable than Free version, you can download the latest version through the following link. If the issue still exists, please offer the following message to help us reproduce your issue and work out a solution for you, thanks for your assistance in advance.

Spire.Pdf 9.1.4 for Java: https://www.e-iceblue.com/Download/pdf-for-java.html
Spire.Pd f9.1.0 for Net: https://www.e-iceblue.com/Download/down ... t-now.html

1) The input Pdf file, you can attach here or send it to us via email ([email protected]).
2) The full test code that can reproduce your issue.
3) The OS version of Mac, such as Mac os 12.4

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Wed Jan 18, 2023 10:50 am

I tried Spire.Pdf 9.1.0 for Net but it didn't change anything for me.

The code is running on MacOS Ventura 13.1 (22C65).

There is no exception message with the sample code but the stack is:
Code: Select all
   at sprᜄ.ᜀ(Int32 A_0)
   at sprᜄ.ᜂ(Int32 A_0)
   at sprᜄ.ᜆ()
   at sprᜄ.ᜉ()
   at sprᜄ..ctor(Stream A_0, Boolean A_1)
   at sprᜄ..ctor(Stream A_0)
   at sprᦃ.ᜁ(Stream A_0)
   at sprᦃ.ᜁ(Byte[] A_0)
   at sprᥳ.ᜀ(Byte[] A_0, sprᝳ A_1)
   at spr᥸.ᜀ(Byte[] A_0, String A_1, sprᝳ A_2)
   at spr᥸.ᜅ()
   at sprᥝ.ᜆ()
   at spr៬.ᜀ(ᜂ A_0)
   at spr៬.ᜄ.ᜁ()
   at spr៬.ᜀ(sprᝧ A_0)
   at spr៯.ᜂ(sprᝧ A_0)
   at spr᝻.ᜂ()
   at spr᝻.ᜀ()
   at spr᝻.ᜁ()
   at spr៯.ᜂ(sprᝧ A_0)
   at Spire.Pdf.Widget.PdfPageCollection.ᜀ(Int32 A_0, Int32& A_1, Boolean A_2)
   at Spire.Pdf.Widget.PdfPageCollection.ᜀ(Int32 A_0)
   at Spire.Pdf.Widget.PdfPageCollection.get_Item(Int32 index)
   at Spire.Pdf.PdfDocumentBase.ᜀ(Int32 A_0, Int32 A_1, Int32 A_2)
   at Spire.Pdf.PdfDocument.SaveAsImage(Int32 pageIndex, Int32 dpiX, Int32 dpiY)
   at Sample_SpirePdf.MainPage.PDF2PNG(String filepath, Int32 pageNumber) in /Volumes/Data/GitWare/Apps/AnybookPro/R&D/Sample_SpirePdf/MainPage.xaml.cs:line 27


You'll find the PDF at the root of the code.
Sample_SpirePdf.zip


Regards,
Michael

MichaelE
 
Posts: 2
Joined: Wed Jan 18, 2023 2:49 am

Thu Jan 19, 2023 10:01 am

Hello,

Thanks for your feedback.
The NET7 dlls in our Spire.PDF has dependency on the Spire.Drawing.Common. This library is not supported on non-windows operating system from NET6. Please refer to: https://learn.microsoft.com/en-us/dotne ... ndows-only

To avoid this issue, you can install the latest Spire.Officefor.NETStandard 8.1.1 via NuGet installation. It includes our Spire.PDF product. And you need to modify your code in mac platform, please refer to the following code. If you have any problems after testing, please feel free to contact us.
Code: Select all
Stream stream = new MemoryStream();
            stream = pdfDocument.SaveAsImage(0);
            stream.Position = 0;
            String result = @"..\..\..\output\result_SaveAsImage0.png";
            byte[] buffer = new byte[stream.Length];
            stream.Read(buffer, 0, buffer.Length);
            File.WriteAllBytes(result, buffer);


Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Sun Jan 29, 2023 7:22 am

Hello,

Greeting from E-iceblue.
Does the solution I provided solve your issue? Could you give some feedback at your convenience? Looking forward to your reply.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.PDF

cron