We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Cannot convert Doc to PDF -- SkiaSharp dll not found

I'm trying to convert office documents to pdf so they can be displayed in my Blazor app. 

I've followed the following documentation https://blazor.syncfusion.com/documentation/pdfviewer/how-to/load-office-files but whenever I try I get the following error:


crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: The type initializer for 'SkiaSharp.SKImageInfo' threw an exception.
System.TypeInitializationException: The type initializer for 'SkiaSharp.SKImageInfo' threw an exception.
 ---> System.DllNotFoundException: libSkiaSharp
   at SkiaSharp.SKImageInfo..cctor()
   --- End of inner exception stack trace ---
   at Syncfusion.Drawing.SkiaSharpHelper.Image..ctor(Int32 width, Int32 height)
   at Syncfusion.Drawing.SkiaSharpHelper.Bitmap..ctor(Int32 width, Int32 height)
   at Syncfusion.DocIORenderer.RenderHelper.GetBitmap(Int32 width, Int32 height)
   at Syncfusion.DocIO.Rendering.DrawingContext.CreateBitmap(Int32 width, Int32 height)
   at Syncfusion.DocIO.Rendering.DrawingContext..ctor()
   at Syncfusion.DocIORenderer.DocIORenderer.ConvertToPDF(WordDocument wordDocument)
   at Tonbridge_App.Client.Pages.Files.File.Index.LoadData()
   at Tonbridge_App.Client.Pages.Files.File.Index.OnInitializedAsync()
   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)


I've got the following packages installed:


<PackageReference Include="Syncfusion.Blazor.Themes" Version="20.4.0.49" />
<PackageReference Include="Syncfusion.Blazor.WordProcessor" Version="20.4.0.49" />
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="20.4.0.49" />
<PackageReference Include="Syncfusion.DocIORenderer.Net.Core" Version="20.4.0.49" />
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="20.4.0.49" />

13 Replies

SB Suriya Balamurugan Syncfusion Team February 13, 2023 01:47 PM UTC

Hi Felix,

While converting Office files to PDF in Blazor WASM application, the reported problem occurs due to SkiaSharp dependency.

To resolve the reported problem, kindly do the following steps in your Blazor WASM application,



Please refer our KB documentation to know about how to convert Word to PDF in Blazor WASM app,
https://www.syncfusion.com/kb/13871/how-to-convert-word-to-pdf-in-blazor-webassembly-wasm

Note: We will plan to update these details in this documentation also.

Regards,
Suriya Balamurugan.



FM Felix McDougle February 17, 2023 02:08 PM UTC

Thanks - that worked perfectly when running locally, but the same issues come back as soon as it's deployed to Azure.





AA Akash Arul Syncfusion Team February 20, 2023 07:59 PM UTC

Felix, we tried to reproduce the reported issue by publishing the Blazor WASM application in Azure App Service PremiumV3 (P2v3). But it worked properly without any issue in our end.

Can you please share the details of the platform in Azure(Example: Azure App Service Linux, Azure Kubernetes Service…) that you tried to publish the sample. This will be helpful for us to replicate the reported issue in the respective platform. And so that we can share the solution as soon as possible.



FM Felix McDougle replied to Akash Arul February 22, 2023 10:13 AM UTC

Hi Akash,


When I'm programming the application it's on MacOS dotnet 7 and it's being deployed via GitHub Actions to an Azure App Service - Windows (using dotnet 7)


Thanks



SB Suriya Balamurugan Syncfusion Team February 23, 2023 06:06 PM UTC

Felix, on our side, we are currently checking with our organization to set up a similar environment (deploy via GitHub Actions to an Azure App Service - Windows (using dotnet 7)) to replicate the exact problem and will update further details on 27th February 2023.

Meantime, we have attached the Blazor WASM sample in net7.0 target.
We suggest you to deploy the attached sample at your end and provide us confirmation whether you are facing issue in this sample.

If the issue is not reproduced using the attached sample application at your end, then could you please modify the attached sample as an issue reproducible sample application and share us.


Which will be helpful to reproduce the exact issue at our end and will provide you appropriate solution at the earliest.


Attachment: Clientsideapplication_afb558c5.zip


FM Felix McDougle replied to Suriya Balamurugan February 27, 2023 08:59 AM UTC

Hi,


The project you sent is not the same as the one I am using. It's a WebAssembly ASP.NET Core Hosted application so it also has a server and shared project.



Everything else is the same as your code. 



AA Akash Arul Syncfusion Team February 27, 2023 06:03 PM UTC

Felix, still we are checking with our organization to set up a the environment. Sorry for the delay. We will update you with more details on 28th February 2023.



SB Suriya Balamurugan Syncfusion Team February 28, 2023 05:37 PM UTC

Felix, we set up the environment and reproduced the reported error in Blazor WASM app while deployed via GitHub Actions to an Azure App Service - Windows (using dotnet 7) in our end. We will check and update you with further details on two days.



SB Suriya Balamurugan Syncfusion Team March 3, 2023 08:04 PM UTC

Felix, on further analysis, we have found that the reported exception is due to the SkiaSharp package and not related to Syncfusion Word (DocIO) library.

Internally, we are using the SkiaSharp package as a dependency package of DocIORenderer to convert Word document to PDF. The reported libSkiaSharp exception reproduced in both .NET 6 and .NET 7 when deploy the Blazor client app to Azure App Service (Windows) using GitHub Actions.

We have found the solution to resolve the reported libSkiaSharp issue in .NET 6 target when deploy the Blazor client app to Azure App Service (Windows) using GitHub Actions.

Please do the below steps to resolve the libSkiaSharp issue in .NET 6,

1. Add the WasmBuildNative property group in Blazor client csproj file.


2. Add the “dotnet workload restore” command before the build command in the GitHub workflow (YAML) file.


Please find the .NET 6 Blazor client sample application and its GitHub workflow (YAML) file from the below attachment.

We are facing some other problems due to SkiaSharp in .NET 7 which are specific to SkiaSharp package and not related to our Word library. Currently, we are investigating further to resolve the reported libSkiaSharp issue in .NET 7

Until, we suggest you to use .NET 6 along with above suggestion.




Attachment: BlazorNET6_5ee643ce.zip


FM Felix McDougle March 6, 2023 12:09 PM UTC

Thanks for this; however, we cannot, and are not willing to, roll back to using .NET 6, so please keep me informed on when it will work on .NET 7.


Thanks,



SB Suriya Balamurugan Syncfusion Team March 8, 2023 07:35 PM UTC

Felix, as we mentioned earlier, the reported problem is due to the SkiaSharp library which in one of the dependent on DocIORenderer library. We have reported this issue to SkiaSharp team. Once the reported issue resolved by the SkiaSharp team, we will update you the details.

Please find the bug report created for SkiaSharp team
,
https://github.com/mono/SkiaSharp/issues/2411

We will follow the above link to know the status of the issue and keep trying out the solutions provided by SkiaSharp team.



FM Felix McDougle May 23, 2023 08:14 AM UTC

Hi,


Any update on this? If there isn't an update, I think you need to start looking at using a different package...


Felix



AN Anto Nihil Sahaya Raj Syncfusion Team May 24, 2023 05:24 PM UTC

Felix, we are using SkiaSharp library for long years and also in multiple environments  ( as an alternative for System.Drawing GDI functionalities). During Word to PDF conversion, we are measuring each contents (text, images, shapes) to layout the contents and preserve in the position as like Microsoft Word application. Because, the position and layouting information are not available from Word document file structure. We are facing this problem with specific to particular environment alone. Using the different package instead of SkiaSharp is not feasible at our since it rises more breaks in our existing customers and also it leads to more work to change the entire Word to PDF architecture to preserve contents as equivalent to Microsoft Word.

We will follow up with the below thread and will update you once we got any solution.

https://github.com/mono/SkiaSharp/issues/2411


Loader.
Up arrow icon