Hi Team,
I am using HtmlToPdfConverter with Blink to convert an html string content to pdf in our application.
Ours is .net 6, Blazor application.
Everything works fine on local Windows machine. But on server its deployed in Docker Linux container.
So, I have added both Windows and Linux NuGet packages on to the application:
syncfusion.htmltopdfconverter.net.linux - 20.3.0.58
syncfusion.htmltopdfconverter.net.windows - 20.3.0.58
I also followed the below url to make it work on Docker Linux platform
https://www.syncfusion.com/kb/11299/how-to-convert-html-to-pdf-using-blink-in-linux-docker
Still, I am getting the "Failed to convert webpage" error
I am trying to troubleshoot using the below link
https://help.syncfusion.com/file-formats/pdf/convert-html-to-pdf/troubleshooting
I have few queries on this.
We have checked the reported issue with provided details on our end but it is working properly. We have attached the sample for your reference and try the sample on your end and let us know the result
Sample link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/HTMLBlzorApplication803260995
Please make sure to add the below command line argument in our converter
//Set command line arguments to run without sandbox. settings.CommandLineArguments.Add("--no-sandbox"); settings.CommandLineArguments.Add("--disable-setuid-sandbox"); |
1.Is there an alternative for Newtonsoft.Json assembly binding redirection on .net 6? as this is mentioned as one of the possibilities. |
The reported issue does not occur due to NewtonSoft. Json assembly |
2.Which Newtonsoft.Json version does it actually support without throwing error?
|
You should use NewtonSoft. JSON 13.0.1 or 13.0.2 version It does not throw errors. |
3.If I set the TempPath, will the BlinkPath be updated to this new path? or should I set the BlinkPath manually? or can the BlinkPath be left as is?
|
TempPath and BlinkPath are both different. The BlinkBinaries folder will be copied from the NuGet package to your application's bin folder. So there is no need to manually set BlinkPath. If we set the TempPath, then the conversion will use that path to generate the temporary files. During the HTML to PDF conversion process, internally, the converter will create a temporary process file, a PDF file, and a text file in a temporary folder. These files will be deleted once the conversion process is complete. |
4.Instead of installing the additional assemblies mentioned for Docker Linux usage, every time the docker image is created, can these assemblies be copied to any particular location so that this can be used by blink assemblies?
|
Yes. You can copy the assemblies to any particular location, but you will get some problems while upgrading the nuget package. As of now, we are installing the assemblies. So we have suggested that it is better to install it every time.
|
5.Can we somehow get more specific error message on these scenarios.
|
The "Failed to convert webpage" error will occur when a document is not generated properly in Chrome. Other types of exceptions are handled properly. This exception could happen for the following
reasons: All of the above We can't identify the cause, but we can identify the failure when conversion fails. We didn't get a proper exception at chrome level. Please refer below documentation page
https://help.syncfusion.com/file-formats/pdf/convert-html-to-pdf/troubleshooting |
6.Are there any other reference materials or samples that can be of use in this scenario?
|
You can download the sample from below link https://help.syncfusion.com/file-formats/pdf/convert-html-to-pdf/docker
https://github.com/SyncfusionExamples/html-to-pdf-csharp-examples/tree/master/Docker
https://www.syncfusion.com/kb/8749/how-to-convert-html-to-pdf-in-linux-docker-container
|
Hi,
The 3 main causes that you mentioned above:
We have checked the reported issue with given details but its working properly on our end.We have attached the sample for your reference.Please try the sample on your end and let us know the result.
Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/Linuxdocker1119983433
If still you have facing any issue,Can we have web meeting to directly look into the reported issue on your machine.Please let us know your availability for a web meeting, we will make every effort to have this scheduled at a date and time of your convenience.
Note: We work during IST hours.(8 am to 7.30 PM IST)
HI Santhiya,
Thanks for the sample project. I tried your solution. It's all working fine in my local machine.
I had some doubts about the solution in which I added this HtmlToPdfConverter. As this solution contains so many other features implemented in it. So, I separated it into a new service that we are currently introducing.
Even now, everything works fine in local machine. But once deployed to server, I still get the same error, "Failed to convert webpage"
I tried adding code to create a dummy file and delete from the TempPath folder. It works fine. So, TempPath has enough elevated permissions.
I checked the BlinkBinariesLinux path as well in the server.