Exception: failed to convert the webpage

Hello dear syncfusion team,

i´m using the HTML to PDF converter, to create a PDF document by a url. My application has the Windows authentication & ASP.NET Impersonation enabled. 
My application pool identity use the Built-in account: ApplicationPoolIdentity. In this combination, i got the exception "failed to convert the webpage" on the line: 

Syncfusion.Pdf.PdfDocument document = htmlConverter.Convert(fullUrl);

I already added the WebKitPath in the WebKitConverterSettings also the Username and Password properties. 
https://help.syncfusion.com/file-formats/pdf/convert-html-to-pdf/webkit#windows-authentication

But if I change the application pool identity to Custom account "for example: Administrator" -> it works... 
Hopefully you have some ideas, which kind of access the dlls needs to run. I think its a simply access problem. 

6 Replies 1 reply marked as answer

GK Gowthamraj Kumar Syncfusion Team September 29, 2020 01:12 PM UTC

Hi Philipp, 

Thank you for using Syncfusion products. 

The reported exception may occurs due to the missing of pre-requisites/permission in the machine. So, please ensure the dependencies are properly configured in the machine. WebKit HTML converter internally creates and launches a surrogate process from a temporary folder. So, the converter required read/write and execute permission of the temporary folder. If the temporary folder does not have the elevated permission, the reported exception may occurs. So, kindly ensure the respective user group has the permission for the temp folder.  

However, we can provide a particular path as temp path which has the elevated permission using TempPath property in WebKitConverterSettings then the converter will make use of system temporary folder for creating temporary files. Then make sure the temp folder has read/write/execute permission of IIS_IUSRS user group. Also, kindly try the conversion with Local System identity and let us know the result.  

Refer below links to troubleshooting the HTML converter.  

Refer below KB link for resolving the failed to convert web page exception, kindly try the provided solutions and let us know the result.  

If still the same exception occurs, kindly let us know the details about your server environment such as (OS, Bit version, culture settings, RAM etc.,), complete HTML file/URL, complete code snippet and product version. So that we can try the conversion in same environment to reproduce the exception in our end. So, that it will be helpful for us to analyze and assist you further on this. 

Gowthamraj K. 



PP Philipp Pudell September 29, 2020 03:28 PM UTC

i´m sorry but i tried already all ways cases. Maybe it helps if you see a part of my stacktrace. 

I tried to set the permission to "every" for the tmp folder. Under high permission (application pool identity), i saw some tmp files and i got my pdf. But with the build-in account it dont work. 



OS: Windows Server 2016 Standard

RAM: 32GB

System type: 64-bit OS, 64x-bases processor


Syncfusion.HtmlToPdfConverter.QtWebKit.AspNet.Mvc: 518.1.0.42


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3650.0


Thread information:

Thread ID: 23

Thread account name: ----------

   Is impersonating: True

   

Stack trace:

at Syncfusion.Pdf.HtmlToPdf.HtmlToPdfResult.RenderWebKit(PdfPageBase page, PdfLayoutFormat format) +16554

at Syncfusion.Pdf.HtmlToPdf.HtmlToPdfResult.Render(PdfPageBase page, PdfLayoutFormat format) +175

at Syncfusion.HtmlConverter.HtmlToPdfConverter.Convert(String url) +1990




string baseUrl = HttpContext.Current.Server.MapPath("~");


HtmlToPdfConverter htmlConverter =  new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);

               

WebKitConverterSettings webKitSettings = new WebKitConverterSettings()

               {

                   PdfPageSize = new SizeF(PdfPageSize.A4.Width, 40),

                   Orientation = PdfPageOrientation.Landscape,

                   WebKitViewPort = new Size(1024, 0),

                   WebKitPath = baseUrl + @"\QtBinaries\",

                   TempPath = Settings.WebConfig.GetTempPath03(),

                   //TempFileName = "Syncfusion",

                   Username = Settings.WebConfig.GetServiceUsername(),

                   Password = Settings.WebConfig.GetServicePassword()

               };

               

htmlConverter.ConverterSettings = webKitSettings;

             

string fullUrl = url + "/Form/PDF/?ID=" + id.ToString();

               

Syncfusion.Pdf.PdfDocument document = htmlConverter.Convert(fullUrl); //<-- error line



GK Gowthamraj Kumar Syncfusion Team September 30, 2020 02:14 PM UTC

Hi Philipp, 
 
Thank you for your update. 
 
Currently we are creating the same environment in our end and we will update the further details on October 5th 2020. 
 
Regards, 
Gowthamraj K 



GK Gowthamraj Kumar Syncfusion Team October 5, 2020 12:47 PM UTC

Hi Philipp, 

Thank you for your patience. 

We have tried to reproduce the reported exception in our end, but it is working properly. We have created a sample and convert the pdf document, it generates a PDF document properly. We were not able to reproduce the exception and we have shared the sample for your reference. We suspect that issue may occurs due that particular HTML file. Kindly please run the sample in your end and let us know the result. 

 
If still the same exception occurs, kindly let us know the details about your HTML file/URL, modified sample and product version to reproduce the issue. So, that it will be helpful for us to analyze and assist you further on this.  

Regards, 
Gowthamraj K 


Marked as answer

PP Philipp Pudell September 29, 2021 03:34 PM UTC

The Sample didn't work...


Failed to convert the webpage

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.


Exception Details: Syncfusion.Pdf.PdfException: Failed to convert the webpage


Source Error:


An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:



[PdfException: Failed to convert the webpage]

Syncfusion.Pdf.HtmlToPdf.HtmlToPdfResult.RenderWebKit(PdfPageBase page, PdfLayoutFormat format) +16554

Syncfusion.Pdf.HtmlToPdf.HtmlToPdfResult.Render(PdfPageBase page, PdfLayoutFormat format) +175

Syncfusion.HtmlConverter.HtmlToPdfConverter.Convert(String htmlString, String baseUrl) +2109


Current:



With a custom Identity it works fine.



GK Gowthamraj Kumar Syncfusion Team September 30, 2021 03:49 PM UTC

Hi Philipp,

Thank you for your update.

 
We have tried the above sample on our end, but it is working properly. As we said earlier, we internally creates and launches a surrogate process from a temporary folder. So, the converter required read/write and execute permission of the temporary folder. If the temporary folder does not have the elevated permission, the reported exception may occurs. So, please make sure this path has required permission for the respective user group (IIS_IUSRS). If you are hosting the application in IIS, please try to add IIS_IUSRS user group and provide full access permission to the temp folder.   

If the machine blocks (prevents the execution of the process) the temporary surrogate process. If you are using any software/program to block the unknown executables, you can whitelist the temporary surrogate process using two ways.  
  • You can allow the executables from the particular folder and set the path of the folder as TempPath in WebKitConverterSettings.
  • You can allow the executable with name, you can settings any name to process using TempFileName property. (If we set this property, the temporary process will be created with this name)

Refer below KB link for resolving the failed to convert web page exception, kindly try the provided solutions and let us know the result.   

Regards, 
Gowthamraj K     


Loader.
Up arrow icon