Reputation: 96
I am trying to convert HTML files to PDF using PDFTron with the HTML2PDF modules.
The issue only manifests when running inside a docker image (I tried using ubuntu:22.04 and mcr.microsoft.com/dotnet/aspnet:7.0.11 but neither worked). The conversion works both on windows and on ubuntu 22.04 inside a GitHub actions workflow (when running tests).
When I run the conversion inside a docker image I get the following exception:
pdftron.Common.PDFNetException: Exception:
Message: Child process wait result (wstatus): 0
Conditional expression: exit_code == 0
Version : 10.4.0-cae97e1
Platform : Linux
Architecture : AMD64
Filename : Html2Pdf.cpp
Function : Convert
Linenumber : 447
at void pdftron.Common.PDFNetException.REX(IntPtr result)
at bool pdftron.PDF.HTML2PDF.Convert(PDFDoc doc)
Here is my docker file:
FROM ubuntu:22.04
RUN apt-get update && apt-get install -y libreoffice
RUN apt-get install libnss3 -y
RUN apt-get install fontconfig -y
WORKDIR /app
COPY Artifacts/Demo ./
EXPOSE 80
ENV ASPNETCORE_URLS=http://+:80
ENV DOTNET_RUNNING_IN_CONTAINER=true
ENTRYPOINT ["/app/MyApp"]
When examining the tmp files produced by the headless chromium which pdftron uses, I can see the created pdf file (/tmp/pdftron/the unique id used by pdftron), and it looks as expected.
Here are the created files for one conversion:
-rw------- 1 root root 119418 Sep 18 13:42 Trn-1-1695044549-ab5ecde2-5df9-4e46-b9b3-a18499513196
-rw-r--r-- 1 root root 12259 Sep 18 13:42 Trn-1-1695044549-e2a18a71-b4a0-4451-b560-2447cc51a958
I have also noticed that changing the temp path during initialization does not actually change the temp path
PDFNet.SetTempPath(Path.Combine(_options.Value.TempFolderPath, "pdftron"));
PDFNet.Initialize(_options.Value.LicenseKey);
Upvotes: 0
Views: 295