Hi,
I'm using Syncfusion ASP.NET Core with Pdf Viewer component.
<PackageReference Include="Syncfusion.EJ2.PdfViewer.AspNet.Core" Version="25.1.39" />
Amazon Linux - Version 2023.4.20240528
Dockerfile
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
RUN ln -s /lib/x86_64-linux-gnu/libdl.so.2 /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
WORKDIR /app
# Copy everything
COPY . ./
WORKDIR /app/src/Viewer
# Restore, Build and Publish a release
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0
ENV DOTNET_EnableDiagnostics=0
ENV ASPNETCORE_URLS http://*:5003
ENV ASPNETCORE_ENVIRONMENT Production
Hi Otto,
The reported issue
occurs when the PDFium dependency is missing in the environment. If you are
using the PDF Viewer with Docker in the .NET 8.0 framework, please refer to the
Dockerfile below for instructions on how to install the PDFium dependency:
Kindly compare the above Dockerfile and modify your Dockerfile accordingly and let us know, if you are facing any issues.
Hi Chinnamunia,
Thanks for your help.
Problem solved.
Analyzing your Dockerfile, I saw that the problem was the execution order of the runtime libraries, so I solved the problem by placing the part of the code that executes the libraries after building the runtime image, like this:
# First - Create runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0
# Second
RUN ln -s /lib/x86_64-linux-gnu/libdl.so.2 /lib/x86_64-linux-gnu/libdl.so
# Install the native System.Drawing dependencies
RUN apt-get update && apt-get install -y --allow-unauthenticated libgdiplus libc6-dev libx11-dev libfontconfig
RUN ln -s libgdiplus.so gdiplus.dll
After that, I had a problem with SkiaSharp rendering the PDF.
We solved this problem by adding a package “<PackageReference Include=”SkiaSharp.NativeAssets.Linux“ Version=”2.88.8“ />” in my project and adding this point “libfontconfig” in this line “RUN apt-get update && apt-get install -y --allow-unauthenticated libgdiplus libc6-dev libx11-dev libfontconfig”
My final Dockerfile:
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
WORKDIR /app
# Copy everything
#COPY . ./
COPY ["src/Viewer/EClic.UI.Viewer", "./Viewer"]
WORKDIR /app/Viewer
# Restore, Build and Publish a release
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0
RUN ln -s /lib/x86_64-linux-gnu/libdl.so.2 /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 libfontconfig
RUN ln -s libgdiplus.so gdiplus.dll
ENV DOTNET_EnableDiagnostics=0
ENV ASPNETCORE_URLS http://*:5003
ENV ASPNETCORE_ENVIRONMENT Production
WORKDIR /app
COPY --from=build-env /app/Viewer/out .
ENTRYPOINT ["dotnet", "EClic.UI.Viewer.dll"]
Thank you very much.
Hi Otto,
Thank you for your
update. We are glad to know that your problem has been solved.
Please let us know if you need any further assistance with this.