Error DynamicPdf.HtmlConverter.NET v1.3.0

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Converter for .NET (v3)  /  Error DynamicPdf.HtmlConverter.NET v1.3.0

DynamicPDF Converter for .NET (v3) Forum

I am has error to  converter html to pdf:

Conversion failed. Refer inner exception for details.
 at ceTe.DynamicPDF.Conversion.DevTools.RuntimeCLI.Chrome.<CreateNewSession>d__6.MoveNext()<---
sending the request. ---> System.Net.Http.CurlException: Couldn't connect to server
   at System.Net.Http.CurlHandler.ThrowIfCURLEError(CURLcode error)
   at System.Net.Http.CurlHandler.MultiAgent.FinishRequest(StrongToWeakReference`1 easyWrapper, CURLcode messageResult)
   --- End of inner exception stack trace ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at System.Net.Http.HttpClient.<FinishSendAsyncUnbuffered>d__59.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at System.Net.Http.HttpClient.<GetStringAsyncCore>d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ceTe.DynamicPDF.Conversion.DevTools.RuntimeCLI.Chrome.<CreateNewSession>d__6.MoveNext()
   --- End of inner exception stack trace ---
   at ceTe.DynamicPDF.HtmlConverter.Converter.l.MoveNext()
---> (Inner Exception #0) System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.Http.CurlException: Couldn't connect to server
   at System.Net.Http.CurlHandler.ThrowIfCURLEError(CURLcode error)
   at System.Net.Http.CurlHandler.MultiAgent.FinishRequest(StrongToWeakReference`1 easyWrapper, CURLcode messageResult)
   --- End of inner exception stack trace ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at System.Net.Http.HttpClient.<FinishSendAsyncUnbuffered>d__59.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at System.Net.Http.HttpClient.<GetStringAsyncCore>d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ceTe.DynamicPDF.Conversion.DevTools.RuntimeCLI.Chrome.<CreateNewSession>d__6.MoveNext()<---



.Net Core 2.2;
Host: Openshift -container Linux
Posted by a ceTe Software moderator
Hello,

HtmlConverter uses Chromium to do the conversions, do you have chromium installed in your Linux machine? Also, you will have to set the chromium path using the ChromiumProcessPath property of the Converter. And please try setting a temp directory to avoid any file access issues. Below is the sample code for this.

Converter.ChromiumProcessPath = @"/home/hc/chrome";
Converter.TemporaryDirectory = @"/home/hc/tmp/";

Please run the chromium with the no-sandbox and disable-gpu tags. Here are the docker commands:
    RUN echo '#!/bin/bash' > chrome
    RUN echo 'chromium --no-sandbox --disable-gpu $@' >> chrome
    RUN chmod +x chrome

We are continuing to look into this. We'll post an update once we have more information.

Thanks,
ceTe Software Support Team.
There is another way to fix this problem?
In my environment openshift blocks to run chrome

Posted by a ceTe Software moderator
Hello,

DynamicPDF HTML Converter needs access to Chrome or a Chromium browser. Here are the instructions to run HTML Converter on Linux:

Install Chrome or a Chromium-based browser on the system. These instructions will vary depending on the type of Linux you are using.

Test the installation to make sure it runs without errors in headless mode by running this command:
    chromium --headless --no-sandbox --no-gpu

Set the static Converter.ChromiumProcessPath property to the path to your Chromium installation before doing the first conversion.

Set the static Converter.TemporaryDirectory to a directory on your system with read/write access for the application that is using DynamicPDF HTML Converter.

By default, we start the Chromium process on a Linux machine with the “--no-sandbox --no-gpu” arguments. On some systems, you may need to add additional arguments. To do this, set the static Converter.ChromiumProcessArgs property as follows:
    Converter.ChromiumProcessArgs += " --specific-arg"

Thanks,
ceTe Software Support Team.
Hi.

Is it possible to remove the default parameters, and only use parameters provided like this: Converter.ChromiumProcessArgs = "--params..."?
Seems like the default parameters is always included, the newest version of the Chromium browser doesn't need the --siable-gpu parameter if on uses --headless.

Christer.
Posted by a ceTe Software moderator
Hello Christer,

These flags are being added by default on Linux because most systems require them. If you would like to suppress the default parameters, you can set an empty string or specify specific parameters.

Here is a pseudocode.
Converter.ChromiumProcessArgs = "";
or
Converter.ChromiumProcessArgs = " --specific-args";

Thanks,
ceTe Software Support Team
Hello! I'm Misael
I have the same problem in a windows container image base 4.8-20211109-windowsservercore-ltsc2019.
I've installed Chrome by chocolatey, I've tried to set the parameters to the installation path, but to no avail, how can I perform the string to html conversion in this situation?
Thanks!
Posted by a ceTe Software moderator
Hi,

Please try using the latest version (v1.07 or later) of DynamicPDF HTML Conveter for .NET and see it works for you. You can download latest from NuGet (Package ID: ceTe.DynamicPDF.HtmlConverter.NET) or from our website here.

Also refer to the documentation on Container Deployment here.

Thanks,
ceTe Software Support Team
I update the version for 1.7, i set the  ChromiumProcessPath for C:\Program Files\google\Chrome\Application\, but the error runs:

Unable to initialize the process. Refer the inner execption for more details.
at ceTe.DynamicPDF.HtmlConverter.Converter.c()
   at ceTe.DynamicPDF.HtmlConverter.Converter.d()
   at ceTe.DynamicPDF.HtmlConverter.Converter.o.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ceTe.DynamicPDF.HtmlConverter.Converter.h.a.MoveNext()

I using windows container and .net Framework.
Posted by a ceTe Software moderator
Hi,

Please try setting the full path of a chromium exe  and see it works.

Here is a code sample:

Converter.ChromiumProcessPath = @"C:\Program Files\Google\Chrome\Application\chrome.exe";

If you continue facing an issue, then please send over following information to support@dynamicpdf.com so we can look into it further.

1. Simple application to recreate the error.
2. Steps to be followed to recreate(Starting from creating application, deploying, and running).
3. Details on the environment on which the application is running.

Please note, it is difficult to troubleshoot the error without recreating it on our end.

Thanks,
ceTe Software Support Team
I am using byte[] pdfByteArray =await Converter.ConvertAsync(htmlContent); it's working fine in local development but on staging environment it's throwing error
as
Error Message==> "Unable to initialize the process. Please provide valid browser path"
Error StackTrace==> " at ceTe.DynamicPDF.HtmlConverter.Converter.#bmh()
at ceTe.DynamicPDF.HtmlConverter.Converter.#6lh()
at ceTe.DynamicPDF.HtmlConverter.Converter.<>c.#2Bp()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
Posted by a ceTe Software moderator
Hi,

If you are using an older version of DynamicPDF HTML Converter, please try using latest in your application and see if it helps. You can download latest from NuGet (Package ID: ceTe.DynamicPDF.HtmlConverter.NET) or from our website here.

If you continue facing an issue then please send over following information to support@dynamicpdf.com  so we can look into it further.

1. Simple application to recreate the error.
2. Steps to be followed to recreate(Starting from creating application, deploying, and running).
3. Details on the environment on which the application is running.
4. Environment details where in application is working.

Thanks,
ceTe Software Support Team
I am using ceTe.DynamicPDF.HtmlConverter.NET version 1.14.0 and running over Windows it's working and converting HTML string to bytes but in Linux env, it's throwing an error as "unable to initialize the process. please provide valid browser path".

Error Message==> "Init failed. See previous errors."
Error Message==> "Unable to initialize the process. Please provide valid browser path"
Error StackTrace==> " at ceTe.DynamicPDF.HtmlConverter.Converter.#bmh()
at ceTe.DynamicPDF.HtmlConverter.Converter.#6lh()
at ceTe.DynamicPDF.HtmlConverter.Converter.<>c.#2Bp()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
Posted by a ceTe Software moderator
Hi,

Thanks for the information. Since you are deploying the application on a Linux operating system, you will need to set ChromiumProcessPath accordingly. Please refer to the documentation on Linux Deployment here.

Thanks,
ceTe Software Support Team
Dear ceTe Software Support Team,

I followed Container Deployment process and installed chromium in linux env and wrote the following codes

var htmlContent = await GetMailBody(template, "AttachmentTemplate");
Here(l => l.LogInformation("Converting HTML to pdf"));
Converter.ChromiumProcessPath = "/usr/bin/chromium";
Converter.TemporaryDirectory = "dpdfTemp";
byte[] pdfByteArray = await Converter.ConvertAsync(htmlContent);

but still getting issues  saying ->

Error Message==> "Unable to initialize the process. Refer the inner execption for more details."
Error StackTrace==> " at ceTe.DynamicPDF.HtmlConverter.Converter.#bmh()
at ceTe.DynamicPDF.HtmlConverter.Converter.#6lh()
at ceTe.DynamicPDF.HtmlConverter.Converter.<>c.#2Bp()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state).

Regards,
Md Shafique Ziya
Posted by a ceTe Software moderator
Hi,

We reviewed the information you posted. Please make sure the folder specified in the temporary path exists on the system/machine.

If you continue facing any issue then please send over following information to support@dynamicpdf.com so we can look into it further.

1. Dockerfile - At least the parts indicating base image and chromium installation commands.
2. Inner exception - It's better print the exception.ToString() instead of message and StackTrace

Thanks,
ceTe Software Support Team
Dear Team,

Thanks for your concern. The issues is resolved.

Regards,
Md Shafique Ziya
Dear ceTe Software Support Team,

I am getting again following error again.

[10:52:22 ERR] Error Message==> Init failed. See previous errors.
[10:52:22 ERR] Error StackTrace==>    at ceTe.DynamicPDF.HtmlConverter.Converter.#6lh()
   at ceTe.DynamicPDF.HtmlConverter.Converter.<>c.#2Bp()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at ceTe.DynamicPDF.HtmlConverter.Converter.#fmh(String #hmh, Uri #imh, Boolean #jmh, ConversionOptions #gmh)
   at ceTe.DynamicPDF.HtmlConverter.Converter.#lsi.#Jsh.#pm()
--- End of stack trace from previous location ---
   at ceTe.DynamicPDF.HtmlConverter.Converter.ConvertAsync(String inputHtml, Uri basePath, ConversionOptions conversionOptions)


Earlier it was working.


Integration:

 try
 {
     Converter.ChromiumProcessPath = "../usr/bin/chromium";
     Converter.TemporaryDirectory = "dpdfTemp";
     Here(l => l.LogTrace("ChromiumProcessPath =>{ChromiumProcessPath}", Converter.ChromiumProcessPath));
     return await Converter.ConvertAsync(htmlContent);
 }
 catch (Exception ex)
 {
     Here(l => l.LogError("Error Message==> {Message}", ex.Message));
     Here(l => l.LogError("Error StackTrace==> {StackTrace}", ex.StackTrace));
     return null;
 }
Dear ceTe Software Support Team,

I am getting again following error again.

[10:52:22 ERR] Error Message==> Init failed. See previous errors.
[10:52:22 ERR] Error StackTrace==>    at ceTe.DynamicPDF.HtmlConverter.Converter.#6lh()
   at ceTe.DynamicPDF.HtmlConverter.Converter.<>c.#2Bp()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at ceTe.DynamicPDF.HtmlConverter.Converter.#fmh(String #hmh, Uri #imh, Boolean #jmh, ConversionOptions #gmh)
   at ceTe.DynamicPDF.HtmlConverter.Converter.#lsi.#Jsh.#pm()
--- End of stack trace from previous location ---
   at ceTe.DynamicPDF.HtmlConverter.Converter.ConvertAsync(String inputHtml, Uri basePath, ConversionOptions conversionOptions)


Earlier it was working.


Integration:

 try
 {
     Converter.ChromiumProcessPath = "../usr/bin/chromium";
     Converter.TemporaryDirectory = "dpdfTemp";
     Here(l => l.LogTrace("ChromiumProcessPath =>{ChromiumProcessPath}", Converter.ChromiumProcessPath));
     return await Converter.ConvertAsync(htmlContent);
 }
 catch (Exception ex)
 {
     Here(l => l.LogError("Error Message==> {Message}", ex.Message));
     Here(l => l.LogError("Error StackTrace==> {StackTrace}", ex.StackTrace));
     return null;
 }
Dear ceTe Software Support Team,

I am getting again following error again.

[10:52:22 ERR] Error Message==> Init failed. See previous errors.
[10:52:22 ERR] Error StackTrace==>    at ceTe.DynamicPDF.HtmlConverter.Converter.#6lh()
   at ceTe.DynamicPDF.HtmlConverter.Converter.<>c.#2Bp()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at ceTe.DynamicPDF.HtmlConverter.Converter.#fmh(String #hmh, Uri #imh, Boolean #jmh, ConversionOptions #gmh)
   at ceTe.DynamicPDF.HtmlConverter.Converter.#lsi.#Jsh.#pm()
--- End of stack trace from previous location ---
   at ceTe.DynamicPDF.HtmlConverter.Converter.ConvertAsync(String inputHtml, Uri basePath, ConversionOptions conversionOptions)


Earlier it was working.


Integration:

 try
 {
     Converter.ChromiumProcessPath = "../usr/bin/chromium";
     Converter.TemporaryDirectory = "dpdfTemp";
     Here(l => l.LogTrace("ChromiumProcessPath =>{ChromiumProcessPath}", Converter.ChromiumProcessPath));
     return await Converter.ConvertAsync(htmlContent);
 }
 catch (Exception ex)
 {
     Here(l => l.LogError("Error Message==> {Message}", ex.Message));
     Here(l => l.LogError("Error StackTrace==> {StackTrace}", ex.StackTrace));
     return null;
 }


Regards,
Md Shafique Ziya
nnbbss
Спасибо предназначенных для предоставления этих видов великолепно публикация. 
взгляните и мою страничку и дайте ей оценку
 
 
 
 
 
 
=0090=0=

All times are US Eastern Standard time. The time now is 12:23 AM.