Hi,
I have a ASP.NET Core app that has a controller that serves my Blazor client app for .pdf-files. The controller is set up as one of your documents suggests. It was working fine until i upgraded my server and client apps to .net 6. The "Load" and "RenderPDFPages" endpoints are hit correctly but the "pdfviewer.GetPage(jsonObject);" call in "RenderPDFPages" endpoint results string object with value "The type initializer for 'Gdip' threw an exception."
I'm guessing that there might be something wrong with my docker image generation. Here's current dockerfile:
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
ARG ENVIRONMENT=Release
ENV ASPNETCORE_ENVIRONMENT=$ENVIRONMENT
RUN sed -i'.bak' 's/$/ contrib/' /etc/apt/sources.list
RUN apt-get update; apt-get install -y ttf-mscorefonts-installer fontconfig
RUN apt-get update \
&& apt-get install -y --allow-unauthenticated \
libc6-dev \
libgdiplus \
libx11-dev \
curl \
vim \
supervisor \
procps
Any suggestions to fix this? Why those methods in used in the pdf viewer controller doesn't throw on exceptions? Only visible indication that i get from these kind of errors is that i get the pdf viewer in the client app prompt that same generic message of pdf viewer depending on server. Would be lot better if those endpoints would throw or that the client component would indicate that server produced error.
Current syncfusion version is 19.3.0.53 for all libraries.
-Ville
Query |
Details | |
I have a ASP.NET Core app that has a controller that serves my Blazor client app for .pdf-files. The controller is set up as one of your documents suggests. It was working fine until i upgraded my server and client apps to .net 6. The "Load" and "RenderPDFPages" endpoints are hit correctly but the "pdfviewer.GetPage(jsonObject);" call in "RenderPDFPages" endpoint results string object with value "The type initializer for 'Gdip' threw an exception."
I'm guessing that there might be something wrong with my docker image generation. Here's current dockerfile:
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
ARG ENVIRONMENT=Release
ENV ASPNETCORE_ENVIRONMENT=$ENVIRONMENT
RUN sed -i'.bak' 's/$/ contrib/' /etc/apt/sources.list
RUN apt-get update; apt-get install -y ttf-mscorefonts-installer fontconfig
RUN apt-get update \
&& apt-get install -y --allow-unauthenticated \
libc6-dev \
libgdiplus \
libx11-dev \
curl \
vim \
supervisor \
procps
Any suggestions to fix this?
|
We have embedded the Pdfium rendering engine in our PDF Viewer for robust rendering, we will create the pdfium.dll based on the operating system during the runtime of the control. So pdfium.dll (libpdfium.so) will be generated on runtime within the project location. Please ensure whether the libpdfium.so is generated properly on your end. And we internally using System.Drawing, it requires libgdiplus to run properly in Linux environment. To work with PDFIUM in the LINUX environment we need to add the following commands in the docker file to install dependencies.
RUN ln -s /lib/x86_64-linux-gnu/libdl-2.24.so /lib/x86_64-linux-gnu/libdl.so
# install System.Drawing native dependencies
RUN apt-get update && apt-get install -y --allow-unauthenticated libgdiplus libc6-dev libx11-dev
RUN ln -s libgdiplus.so gdiplus.dll
Need to execute the following command to install the dependencies.
However, in .NET 6, the System.Drawing.Common NuGet package is only supported on Windows operating systems. Internally we have used the System.Drawing to process the implementation. So, the reported issue occurs on your Linux container.
Please refer to the below links.
| |
Why those methods in used in the pdf viewer controller doesn't throw on exceptions? Only visible indication that i get from these kind of errors is that i get the pdf viewer in the client app prompt that same generic message of pdf viewer depending on server. Would be lot better if those endpoints would throw or that the client component would indicate that server produced error.
Current syncfusion version is 19.3.0.53 for all libraries.
|
You can use the showNotificationDialog property to hide the default notification dialog. And you can use the ajaxRequestFailed event to display the error message in the dialog box by using the given code snippet. We have shared the code snippet for your reference.
Code snippet:
Kindly try this and revert us, if you have any concerns.
|
Thanks for your reply.
I managed to regain APIs functionality to handle PDF-files. I did as suggested in the second link you provided and added a runtimeconfig.template.json -file to my API project root with content:
{
"configProperties": {
"System.Drawing.EnableUnixSupport": true
}
}
However as stated in the article, they might drop all support in future for System.Drawing.Common library in non-windows systems. Any plans to update your library not to use it and keep everything cross platform as it should be?
br. Vil
I ran into the same issue and would like to also request that this be updated
Hi Nyron,
We are glad to announce that our Essential Studio 2022 Volume 1 Main Release V20.1.0.47 is rolled out and is available for download under the following link.
We have implemented the feature implementation and it was included in our volume release V20.1.0.47. Kindly upgrade to that version.
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.
Regards,
Vasugi