PDF to HTML conversion fails on Docker Windows Server Core.

Hi,

I'm having a problem converting PDF to HTML on dockerized Windows Server Core.

Using Syncfusion.HtmlToPdfConverter.Net.Windows nuget lib.


The exception I'm getting on the test app:

Syncfusion.Pdf.PdfException: Failed to create connection
 ---> Syncfusion.HtmlConverter.Blink.ProcessException: Failed to create connection
 ---> System.Net.WebSockets.WebSocketException (0x80004005): Unable to connect to the remote server
 ---> System.Net.Http.HttpRequestException: An error occurred while sending the request.
 ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host..
 ---> System.Net.Sockets.SocketException (10054): An existing connection was forcibly closed by the remote host.
   --- End of inner exception stack trace ---
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Int32>.GetResult(Int16 token)
   at System.Net.Http.HttpConnection.InitialFillAsync(Boolean async)
   at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.WebSockets.WebSocketHandle.ConnectAsync(Uri uri, HttpMessageInvoker invoker, CancellationToken cancellationToken, ClientWebSocketOptions options)
   at System.Net.WebSockets.WebSocketHandle.ConnectAsync(Uri uri, HttpMessageInvoker invoker, CancellationToken cancellationToken, ClientWebSocketOptions options)
   at System.Net.WebSockets.ClientWebSocket.ConnectAsyncCore(Uri uri, HttpMessageInvoker invoker, CancellationToken cancellationToken)
   at Syncfusion.HtmlConverter.Blink.WebSocketTransport.CreateDefaultWebSocket(Uri url, IConnectionOptions options, CancellationToken cancellationToken)
   at Syncfusion.HtmlConverter.Blink.WebSocketTransport.CreateDefaultTransport(Uri url, IConnectionOptions connectionOptions, CancellationToken cancellationToken)
   at Syncfusion.HtmlConverter.Blink.Connection.Create(String url, IConnectionOptions connectionOptions, CancellationToken cancellationToken)
   at Syncfusion.HtmlConverter.Blink.Launcher.LaunchAsync(LaunchOptions options)
   --- End of inner exception stack trace ---
   at Syncfusion.HtmlConverter.BlinkConverter.BlinkResult(Stream outputStream)
   at Syncfusion.HtmlConverter.BlinkConverter.ConvertToPdf(String url, PdfDocument& document)
   --- End of inner exception stack trace ---
   at Syncfusion.HtmlConverter.BlinkConverter.Convert(String url)
   at Syncfusion.HtmlConverter.HtmlToPdfConverter.Convert(String url)
   at WebApplication1111111111.Controllers.WeatherForecastController.GetPdf() in C:\Users\Admin\source\repos\WebApplication1111111111\WebApplication1111111111\Controllers\WeatherForecastController.cs:line 37
   at lambda_method2(Closure, Object, Object[])
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)


The test method I'm calling:


[HttpGet("GetPdf")]

public FileStreamResult GetPdf()

{

    HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();

    var blinkConverterSettings = new BlinkConverterSettings();

    blinkConverterSettings.CommandLineArguments.Add("--no-sandbox");

    blinkConverterSettings.CommandLineArguments.Add("--disable-setuid-sandbox");

    blinkConverterSettings.CommandLineArguments.Add("--no-sandbox --disable-gpu");

    blinkConverterSettings.CommandLineArguments.Add("--disable-software-rasterizer");


    htmlConverter.ConverterSettings = blinkConverterSettings;


    // Convert HTML string to PDF document

    var document = htmlConverter.Convert("https://www.syncfusion.com");


    //Save and close the PDF document.

    var memoryStream = new MemoryStream();

    document.Save(memoryStream);

    document.Close(true);


    // Save to output stream.

    memoryStream.Position = 0;


    return new FileStreamResult(memoryStream, "application/pdf")

    {

        FileDownloadName = $"HTML-to-PDF-5.pdf"

    };

}


The Dockerfile:


FROM mcr.microsoft.com/dotnet/aspnet:8.0-windowsservercore-ltsc2022 AS base

WORKDIR /app


# Azure Web Apps expects port 8080 for Windows containers

EXPOSE 8080


# Download and install WebView2 Runtime silently

RUN curl -L -o MicrosoftEdgeWebView2Setup.exe https://go.microsoft.com/fwlink/p/?LinkId=2124703 && \

   cmd /c MicrosoftEdgeWebView2Setup.exe /silent /install && \

   del MicrosoftEdgeWebView2Setup.exe


# Install Visual C++ Redistributable (required by Chromium)

RUN curl -L -o vc_redist.x64.exe https://aka.ms/vs/17/release/vc_redist.x64.exe && \

    vc_redist.x64.exe /quiet /norestart && \

    del vc_redist.x64.exe


#Copy the published output from the pipeline

COPY . .


# Azure Web App specific environment variables

ENV ASPNETCORE_URLS=http://+:8080

ENV WEBSITE_SITE_NAME=WebApplication1111111111

ENV WEBSITE_HOSTNAME=localhost:8080

ENV ASPNETCORE_ENVIRONMENT=Development


CMD ["dotnet", "WebApplication1111111111.dll"]


4 Replies

KS Karmegam Seerangan Syncfusion Team July 25, 2025 09:42 AM UTC

Hi Alen,


Thank you for reaching out to Syncfusion support.  We are currently checking the reported issue on our end and will provide further updates on July 29th, 2025.


Regards,

Karmegam




KS Karmegam Seerangan Syncfusion Team July 29, 2025 02:40 PM UTC

Hi Alen,


We are able to replicate the reported issue on our end. We are currently validating this issue and will update further details on July 31st, 2025.


Regards,

Karmegam




AM Arumugam Muppidathi Syncfusion Team July 31, 2025 01:04 PM UTC

Hi Alen,


Sorry for the inconvenience caused.

We are currently facing some complexities with running the application in Windows docker using blink converter and are actively working on it. We will share further updates by August 1st, 2025.

Regards,
Arumugam M




KS Karmegam Seerangan Syncfusion Team August 1, 2025 05:17 PM UTC

Hi Alen,


Our HTML to PDF converter internally uses the Blink rendering engine, which relies on a headless Chrome browser to perform the conversion. This ensures that the generated PDF closely matches how the content appears in Chromium-based browsers like Google Chrome, including the print preview output.

Upon further investigation, we found that when running the HTML to PDF conversion inside a Windows Docker container, Chromium fails to launch and crashes during initialization. As a result, the conversion process does not complete successfully in this environment.

We are actively looking into this issue and will update you through this ticket once we identify a solution that enables the Blink rendering engine to function correctly within a Windows container.

 

In the meantime, we kindly recommend using a Linux Docker container for HTML to PDF conversion. Please refer to the following documentation for guidance on setting up and running the converter in a Linux Docker environment:

Documentation: Convert a HTML to PDF file in Docker | Syncfusion

Sample: HTML to PDF conversion in Docker

Please try the suggested workaround and let us know if you need any further assistance.


Regards,
Karmegam


Loader.
Up arrow icon