BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
Hi,
We are running our ASPNet 7.0 application and use Syncfusion to genreate the HTML report into PDF file. Things are working fine when the application is running on windows.
When the application moves to run on container with Alpine linux 3.17 image from MS (https://hub.docker.com/_/microsoft-dotnet-aspnet?tab=description), we got the following errors:
Failed to convert html to pdf. Details: Syncfusion.Pdf.PdfException: An error occurred trying to start process 'xvfb-run' with working directory '/App'. No such file or directory at Syncfusion.HtmlConverter.HtmlConverter.ConvertHtmlToPdf(String url, Int32 width, Int32 height, String tempFile) at Syncfusion.HtmlConverter.HtmlToPdfConverter.Convert(String url) at Syncfusion.HtmlConverter.HtmlToPdfConverter.Convert(String html, String baseurl)
It's understood that there are pre-requsite packages for Linux as mentioned in here (as follow) but we couldn't find all the packages under Alpine 3.17.
Could you please advise how we can get the necessary packages on Alpine Linux?
Our WebKit rendering engine and its dependencies are not working in alpine based Linux docker images. However, we can use our Blink rendering engine in alpine Linux docker images. Please refer below links for more information about Blink rendering engine.
UG: https://help.syncfusion.com/file-formats/pdf/convert-html-to-pdf/blink
KB: https://www.syncfusion.com/kb/11299/how-to-convert-html-to-pdf-using-blink-in-linux-docker
Sample link : https://www.syncfusion.com/downloads/support/directtrac/general/ze/BlinkAlpineDockerNet7-1524766345
We can convert HTML to PDF in alpine based Images using below docker file by installing the chromium in alpine Linux. please try this in your side and let us know the result.
FROM mcr.microsoft.com/dotnet/aspnet:7.0-alpine3.17 AS base RUN apk update && \ apk upgrade && \ apk add --update ca-certificates && \ apk add chromium --update-cache --repository http://nl.alpinelinux.org/alpine/edge/community \ rm -rf /var/cache/apk/* WORKDIR /app EXPOSE 80 EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS build WORKDIR /src COPY ["BlinkAlpineDockerNet7/BlinkAlpineDockerNet7.csproj", "BlinkAlpineDockerNet7/"] RUN dotnet restore "BlinkAlpineDockerNet7/BlinkAlpineDockerNet7.csproj" COPY . . WORKDIR "/src/BlinkAlpineDockerNet7" RUN dotnet build "BlinkAlpineDockerNet7.csproj" -c Release -o /app/build
FROM build AS publish RUN dotnet publish "BlinkAlpineDockerNet7.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "BlinkAlpineDockerNet7.dll"] |
We need to install the below package in docker image and we should use the BlinkBinaries folder from the chromium installed location. Example chromium installed location is “/usr/lib/chromium”. The below commands will install the chromium for alpine docker, we can use the same for the conversion.
RUN apk update && \ apk upgrade && \ apk add --update ca-certificates && \ apk add chromium --update-cache --repository http://nl.alpinelinux.org/alpine/edge/community \ rm -rf /var/cache/apk/* |
Code snippet:
BlinkConverterSettings settings = new BlinkConverterSettings(); //Set Blink path settings.BlinkPath = "/usr/lib/chromium"; |
Please try the above solution and let us know the result.