ConvertToPDF Not Working on VS Code (Mac) - SkiaSharp Issue?

I have a ASP.NET Core project that uses the Word -> PDF converter.  I'm basically using identical code to the example on Syncfusion's website (link).  Also, running the latest version of Visual Studio Code for debugging.

If I debug my project on a Windows 10 machine, everything works fine.  But, if I debug the exact same code on VS Code on an M1 Macbook Pro, I get the following error when I hit this line of code:

PdfDocument pdf = render.ConvertToPDF(wordDoc);

The error is: "The type initializer for 'SkiaSharp.SKImageInfo' threw an exception".

Now, i don't have SkiaSharp as a package in this project.  But when I added it and included it in the @using SkiaSharp; in my code, I still get the same error.

I'm sure this is some sort of Mac/ARM/Unix issue because it works fine everywhere else.  Any help at what I'm missing?

Thanks!!!


7 Replies

MI Miles December 12, 2021 08:38 PM UTC

More Error Details:

Data [IDictionary]:{System.Collections.ListDictionaryInternal}
HResult [int]:-2146233036
HelpLink [string]:null
InnerException [Exception]:{System.DllNotFoundException: Unable to load shared library 'libSkiaSharp' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(liblibSkiaSharp, 0x0001): tried: 'liblibSkiaSharp' (no such file), '/usr/local/lib/liblibSkiaSharp' (no such file), '/usr/lib/liblibSkiaSharp' (no such file), '/Users/[REDACTED]/Documents/Websites/TestSite/liblibSkiaSharp' (no such file), '/usr/local/lib/liblibSkiaSharp' (no such file), '/usr/lib/liblibSkiaSharp' (no such file)
   at SkiaSharp.SkiaApi.sk_colortype_get_default_8888()
   at SkiaSharp.SKImageInfo..cctor()}
Message [string]:"The type initializer for 'SkiaSharp.SKImageInfo' threw an exception."
Source [string]:"Syncfusion.SkiaSharpHelper.Portable"
StackTrace [string]:" at Syncfusion.Drawing.SkiaSharpHelper.Image..ctor(Int32 width, Int32 height)\n at Syncfusion.Drawing.SkiaSharpHelper.Bitmap..ctor(Int32 width, Int32 height)\n at Syncfusion.DocIORenderer.RenderHelper.GetBitmap(Int32 width, Int32 height)\n at Syncfusion.DocIO.Rendering.DrawingContext.CreateBitmap(Int32 width, Int32 height)\n at Syncfusion.DocIO.Rendering.DrawingContext..ctor()\n at Syncfusion.DocIORenderer.DocIORenderer.ConvertToPDF(WordDocument wordDocument)\n at ShowbizJobs.Controllers.AccountController.<Resumes>d__52.MoveNext() in /Users/[REDACTED]/Documents/Websites/TestSite/Controllers/AccountController.cs:line 1026"
TargetSite [MethodBase]:{Void .ctor(Int32, Int32)}
TypeName [string]:"SkiaSharp.SKImageInfo"
Static members
Non-Public members


MR Manikandan Ravichandran Syncfusion Team December 13, 2021 11:55 AM UTC

Hi Miles,

We suspect that the reported issue might be due to not using of SkiaSharp.NativeAssets.Linux or SkiaSharp.NativeAssets.Linux.NoDependencies in your application. So, we suggest you to install the SkiaSharp.NativeAssets.Linux v2.80.2 or SkiaSharp.NativeAssets.Linux.NoDependencies v2.80.2 NuGet package along with Syncfusion.DocIORenderer.Net.Core NuGet while performing Word to PDF conversion and let us know whether it is working fine in your side.

Regards,
Manikandan Ravichandran 



SE Sero Eskandaryan February 2, 2022 11:27 PM UTC

I have the same issue. Here are the libraries i have installed...

<PackageReference Include="SkiaSharp" Version="2.80.3" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.80.3" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.80.3" />
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="19.4.0.48" />
<PackageReference Include="Syncfusion.DocIORenderer.Net.Core" Version="19.4.0.48" />
<PackageReference Include="Syncfusion.Licensing" Version="19.4.0.48" />
<PackageReference Include="Syncfusion.OfficeChart.Net.Core" Version="19.4.0.48" />
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="19.4.0.48" />


MR Manikandan Ravichandran Syncfusion Team February 3, 2022 12:03 PM UTC

Hi Sero,

We have tried to reproduce the reported problem using the simple core application in the Mac environment. But we didn’t face any issue with this. The attached sample will be working in both Windows and Mac environments.

Please check the attached sample at your end and confirm whether it works or not.
https://www.syncfusion.com/downloads/support/forum/171139/ze/ConsoleApp3.1_F171139592005612

From v19.4.0.xx, we recommend using SkiaSharp.NativeAssets.Linux v2.80.2 and HarfBuzzSharp.NativeAssets.Linux v2.6.1.7 NuGet in addition to the Syncfusion.DocIORenderer.Net.Core NuGet packages.

Regards,
Manikandan Ravichandran
 



JS Jamie Saunders February 7, 2022 01:48 PM UTC

Hi,

I'm on a M1 Mac using .NET 6 in arm64 and getting the same issue here too.



JS Jamie Saunders February 7, 2022 02:10 PM UTC

Okie doke, for those that need help. I got this working. I had to use the pre-release version of SkiaSharp.NativeAssets.Linux and HarfBuzzSharp.NativeAssets.macOS (it only exists in pre-release). Could Syncfusion possibly update the documentation, as it makes zero mention of macOS at all, and of course .NET has existed on macOS for a while now.


https://www.nuget.org/packages/HarfBuzzSharp.NativeAssets.macOS/2.8.2-preview.187

https://www.nuget.org/packages/SkiaSharp.NativeAssets.Linux/2.88.0-preview.187


I hope that helps!



LB Lokesh Baskar Syncfusion Team February 8, 2022 04:48 PM UTC

Hi Jamie,

Thank you for your update.
We will check your suggestion in M1 Mac at our end and update our documentation based on that.
Regards,
Lokesh B



Loader.
Up arrow icon