Getting Xvfb failed to start

Hello,

I am getting "Xvfb failed to start" error at at Syncfusion.HtmlConverter.HtmlConverter.ConvertHtmlToPdf(String url, Int32 width, Int32 height, String tempFile)

My environment:

Ubuntu 20.04
.NetCore 3.1
Syncfusion PDF 20.2.0.40

Running the code remotely using VSCODE with application port 5000 forwarded to localhost:5000.

Here's output from installing all dependencies:

xxxx@vulcan:~/repos/xxx$ sudo apt-get update

[sudo] password for xxxx: 

Hit:1 http://us.archive.ubuntu.com/ubuntu focal InRelease

Hit:2 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease                                

Hit:3 https://packages.microsoft.com/ubuntu/20.04/prod focal InRelease                           

Hit:4 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease 

Hit:5 http://us.archive.ubuntu.com/ubuntu focal-security InRelease

Get:6 https://pkgs.tailscale.com/stable/ubuntu focal InRelease

Fetched 6,575 B in 1s (6,492 B/s)

Reading package lists... Done

xxxx@vulcan:~/repos/xxx$ sudo apt-get install xvfb

Reading package lists... Done

Building dependency tree       

Reading state information... Done

xvfb is already the newest version (2:1.20.13-1ubuntu1~20.04.17).

0 upgraded, 0 newly installed, 0 to remove and 74 not upgraded.

xxxx@vulcan:~/repos/xxx$ sudo apt-get install libssl-dev

Reading package lists... Done

Building dependency tree       

Reading state information... Done

libssl-dev is already the newest version (1.1.1f-1ubuntu2.23).

0 upgraded, 0 newly installed, 0 to remove and 74 not upgraded.

xxxx@vulcan:~/repos/xxx$ 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  

Reading package lists... Done

Building dependency tree       

Reading state information... Done

libxcb-icccm4-dev is already the newest version (0.4.1-1.1).

libxcb-image0-dev is already the newest version (0.4.0-1build1).

libxcb-keysyms1-dev is already the newest version (0.4.0-1build1).

libxcb-randr0-dev is already the newest version (1.14-2).

libxcb-render-util0-dev is already the newest version (0.3.9-1build1).

libxcb-render0-dev is already the newest version (1.14-2).

libxcb-shm0-dev is already the newest version (1.14-2).

libxcb-util0-dev is already the newest version (0.4.0-0ubuntu3).

libxcb-xfixes0-dev is already the newest version (1.14-2).

libxcb-xkb-dev is already the newest version (1.14-2).

libxcb1-dev is already the newest version (1.14-2).

libxfixes-dev is already the newest version (1:5.0.3-2).

libxrandr-dev is already the newest version (2:1.5.2-0ubuntu1).

libxrender-dev is already the newest version (1:0.9.10-1).

libx11-dev is already the newest version (2:1.6.9-2ubuntu1.6).

libx11-xcb-dev is already the newest version (2:1.6.9-2ubuntu1.6).

0 upgraded, 0 newly installed, 0 to remove and 74 not upgraded.

🙏 Many thanks in advance for your help.

failed to start


9 Replies

AM Arumugam Muppidathi Syncfusion Team August 23, 2024 01:07 PM UTC

Hi Mark,


Thank you for reaching out to Syncfusion support.

 

We have checked your issue on our end.  Upon further analysis, it seems that you are using QtWebkit rendering engine to perform HTML to PDF conversion in Ubuntu 20.04.  The WebKit rendering engine internally uses the QtWebKit browser to perform HTML to PDF conversion. It is a legacy rendering engine, that has some known rendering issues and limitations, some of the advanced Bootstrap CSS styles are not supported. So we strongly recommended to use our blink rendering engine to perform HTML to PDF conversion.

And also you are using .Net Core 3.1 version of project which is no longer supported so the conversion failed in your case.  So we strongly recommended to use latest version of .NET to get exact result.  We have attached the supported version and non-supported version of .NET

undefined

 


However, we have created .NET 8 console application to perform HTML to PDF conversion using Blink rendering engine in Ubuntu 20.04 as steps mentioned in the below UG documentation. 

UG: https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/linux

You can find sample and output document below for your reference.  

Sample:  HTML-to-PDF-Net8-Linux-584211680
Output: HTML-to-PDF-872004969

 

Please try the above sample and let us know the result. Kindly get back to us if you need further assistance.


Regards,
Arumugam M



MA Mark August 23, 2024 02:24 PM UTC

Hello,


Many thanks for your reply. This is a large legacy application and I am unable to upgrade it to the latest SDK at this time. I have it running successfully on several other servers using Docker. There's something different about this particular environment which I cannot pinpoint. I tried to install everything that is referenced in my Dockerfile. Any other suggestions would be very much appreciated. Could this have anything to do with SSL? I am running the app using https://localhosts:5000.

# syntax=docker/dockerfile:1
FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build-env
WORKDIR /app

# Copy csproj and restore as distinct layers
COPY ./xxx/xxx.Web/*.csproj ./
COPY ./NuGet.config ./
ADD ./pro-packages ./pro-packages
RUN dotnet restore --disable-parallel

# Install nodejs
RUN apt-get update -yq && apt-get upgrade -yq && apt-get install -yq curl git nano
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt-get install -yq nodejs build-essential
RUN npm install -g npm

# Copy everything else and build
COPY ./xxx/xxx.Web/ ./
RUN dotnet publish -c Release -o out

# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:3.1
WORKDIR /app
COPY --from=build-env /app/out .

# Install wkhtmltopdf dependencies
RUN apt-get update -yq && apt-get install -yq libfontconfig libxrender1 libxext6

# Install Syncfusion dependencies
RUN apt-get update -yq && apt-get install -yq xvfb
RUN apt-get update -yq && apt-get install -yq 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

# Set timezone
ENV TZ=US/Central
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y tzdata

ENV ASPNETCORE_URLS=http://*:5000;http://*:5005

ENTRYPOINT ["dotnet", "xxx.Web.dll", "--launch-profile", "'Kestrel_Prod'"]


AM Arumugam Muppidathi Syncfusion Team August 26, 2024 05:03 PM UTC

Hi Mark,


We have checked your issue on our end.  Currently, we are working on creating the application .NETCore 3.1 in Ubuntu 20.04 to replicate the reported issue.  We will update further details on August 28th, 2024


Regards,
Arumugam M



AM Arumugam Muppidathi Syncfusion Team August 28, 2024 04:55 PM UTC

Hi Mark,

We have checked your issue on our end.  Upon further analysis,  we have created ASP .NET MVC .NETCore 3.1 application in Ubuntu 20.04. The HTML to PDF is working fine on our end with the package version 20.2.0.40 in Ubuntu 20.04.  We kindly request you to ensure that your machine has prerequisites installed as mentioned in the below documentation

UG: https://help.syncfusion.com/document-processing/pdf/conversions/html-to-pdf/net/webkit#prerequisites-for-linux

However, we have attached the sample and output document below for your reference

Sample: HtmlToPdfSampleMVC1320624749
Output: Output_(12)-2135495996

Please try the above sample and let us know the result.  Kindly get back to us if you need further assistance.

Regards,

Arumugam M



MA Mark August 28, 2024 08:08 PM UTC

Hello,

Thanks for your reply. This is what I am getting trying to install libssl1.0-dev:

$ sudo apt-get install libssl1.0-dev

[sudo] password for xxxxxxx:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package libssl1.0-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'libssl1.0-dev' has no installation candidate

$ sudo apt-get install libssl-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libssl-dev is already the newest version (1.1.1f-1ubuntu2.23).
0 upgraded, 0 newly installed, 0 to remove and 70 not upgraded.

Also, now when I generate the PDF, a blank is created, no errors or warning.



AM Arumugam Muppidathi Syncfusion Team August 29, 2024 01:52 PM UTC

Hi Mark,


We have checked your issue on our end.  We suspect that the reported issue may occur due to 'libssl1.0-dev' is no longer available for recent Ubuntu versions. Ubuntu now uses newer versions of OpenSSL which is libssl-dev for version 1.1.1. You can find the command below to install OpenSSL libraries


sudo apt-get install libssl-dev

 

 It provides the necessary files for compiling against OpenSSL version 1.1.x.  The below highlighted result occur due to pending upgrades.  You could run 'sudo apt-get upgrade' to ensure all your packages are up to date, which might resolve any related issues.

 

image


Please try the above solution and sample shared in the last response and let us know the result.  Kindly get back to us if you need further assistance.


Regards,
Arumugam M



MA Mark August 31, 2024 11:44 PM UTC

Hello,

I ran your sample project and it worked as expected. This tells me that my environment has all the required dependencies installed. I did notice that you project has SSL folder with 2 files: libcrypto.so and libssl.so. I don't have this in my project. What is the significance of the SSL folder and how is it being referenced?

Here's my code for your reference:

public byte[] HtmlToPdf(string url, string opt)
{
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense(ConfigManager.Instance().GetValue(DefaultEnum.PdfServiceLicenseKey));

byte[] result = null;
HtmlToPdfConverter htmlConverter = GetHtmlToPdfConverter();
System.Diagnostics.Debug.WriteLine($"Using {GetRenderingEngine()} PDF to HTML rendering engine");

// Parse options
dynamic opts = JObject.Parse(opt.TrimToNull() ?? "{}");
System.Diagnostics.Debug.WriteLine($"Using converter options: {opts}");

int marginAll = 50;
if (opts.MarginAll != null) marginAll = int.Parse(opts.MarginAll);
htmlConverter.ConverterSettings.Margin.All = marginAll;

using PdfDocument pdf = htmlConverter.Convert(url);

bool useEncryption = ConfigManager.Instance().GetBoolean(DefaultEnum.PdfAllowEncryption);
if (useEncryption && opts.UserPassword != null)
{
PdfSecurity security = pdf.Security;
security.KeySize = PdfEncryptionKeySize.Key128Bit;
security.Algorithm = PdfEncryptionAlgorithm.RC4;
security.UserPassword = opts.UserPassword;
security.OwnerPassword = "xxxx";
using (MemoryStream s = new MemoryStream())
{
pdf.Save(s);
result = s.ToArray();
}
}
else
{
using (MemoryStream s = new MemoryStream())
{
pdf.Save(s);
result = s.ToArray();
}
}

return result;
}
private HtmlRenderingEngine GetRenderingEngine()
{
string engine = ConfigManager.Instance().GetValue(DefaultEnum.PdfServiceRenderingEngine, "") ?? "";
if (engine.Equals("WebKit")) return HtmlRenderingEngine.WebKit;
else if (engine.Equals("Blink")) return HtmlRenderingEngine.Blink;
else return HtmlRenderingEngine.WebKit;
}




MA Mark September 1, 2024 07:14 PM UTC

Hello,

Thanks to your help and pointers, I was able to figure out that my issue was file permission related. I switched from using a url to file path when doing the conversions. Many thanks again!



AM Arumugam Muppidathi Syncfusion Team September 2, 2024 05:13 AM UTC

Hi Mark,


Thanks for the update.  We are glad to hear that reported issue has been resolved on your end. Kindly get back to us if you need any further assistance.


Regards,
Arumugam M


Loader.
Up arrow icon