Html to pdf linux ubuntu 20.04

I get it work on windows properly but on ubuntu 20.04 didnt.

Installed: 

$ sudo apt-get update
$ sudo apt-get install xvfb
$ sudo apt-get install libssl-dev
$ sudo apt-get install libx11-dev libx11-xcb-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-render-util0-dev libxcb-render0-dev libxcb-shm0-dev libxcb-util0-dev libxcb-xfixes0-dev libxcb-xkb-dev libxcb1-dev libxfixes-dev libxrandr-dev libxrender-dev

plus installed:

# sudo apt-get install libqt5webkit5

Nugets:

Syncfusion.HtmlToPdfConverter.QtWebKit.Net.Core 20.2.0.45
Syncfusion.Pdf.Net.Core 20.2.0.45

I tried first without manually adding QtBinariesLinux folder (thats how it works on windows), than I tried to add this folder (always copy to output) added path for webkit settings, but on ubunu always the same error:

"Message":"Syncfusion.Pdf.PdfException: An error occurred trying to start process \u0027xvfb-run\u0027 with working directory \u0027/app\u0027. No such file or directory\n at Syncfusion.HtmlConverter.HtmlConverter.ConvertHtmlToPdf(String url, Int32 width, Int32 height, String tempFile)\n at Syncfusion.HtmlConverter.HtmlToPdfConverter.Convert(String url)\n at Syncfusion.HtmlConverter.HtmlToPdfConverter.Convert(String html, String baseurl)\n at PDFService.PDFGenerator.ConvertHtmlToPdf(String htmlFile) in /src/PDFService/PDFGenerator.cs:line 39\n at

This is my code from the service:


            HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();

            string baseUrl = string.Empty;

            PdfDocument document = htmlConverter.Convert(htmlFile, baseUrl);

            MemoryStream ms = new MemoryStream();
            
// Save and close the document.
            document.Save(ms);
            document.Close(true);

            //Reset the memory stream position.
            ms.Position = 0;
            
             var fileBytes = ms.ToArray();

            return fileBytes;


Im using ASP Net Core 6.



2 Replies

NI Nikola September 18, 2022 10:20 PM UTC

My mistake, I used docker to publish app, but didnt add in docker file:

RUN apt-get update && apt-get -y install xvfb && apt-get -y install fontconfig && apt-get -y install libssl1.0-dev && apt-get -y install libx11-dev libx11-xcb-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-render-util0-dev libxcb-render0-dev libxcb-shm0-dev libxcb-util0-dev libxcb-xfixes0-dev libxcb-xkb-dev libxcb1-dev libxfixes-dev libxrandr-dev libxrender-dev 


GK Gowthamraj Kumar Syncfusion Team September 19, 2022 01:36 PM UTC

Hi Nikola,


Thank you for your update. We are glad to know that the reported issue is resolved.

The reported exception may occur due to missing of prerequisites and dependent packages in the Linux environment. We need to have all the dependencies in the machine/container in order to perform the conversion inside the machine/container,

https://help.syncfusion.com/file-formats/pdf/convert-html-to-pdf/webkit#prerequisites-for-linux


Please follow the step 5 to install the required dependencies package,

KB: https://www.syncfusion.com/kb/8749/how-to-convert-html-to-pdf-in-linux-docker-container


Please let us know if you need any further assistance in this.


Regards,

Gowthamraj K


Loader.
Up arrow icon