Articles in this section
Category / Section

Failed to convert the webpage exception with WebKit HTML converter

3 mins read

The following are some cases, where the WebKit HTML converter may throw Failed to convert webpage exception and the solution to overcome the exception is given.

Reason

Solution

This exception may occur when converting HTML string with URL to PDF conversion method. 

Make sure to use HTML string to PDF conversion with proper overload methods. Refer to the following links for converting URL to PDF and HTML string to PDF.

 

URL to PDF: https://help.syncfusion.com/file-formats/pdf/convert-html-to-pdf/webkit#url-to-pdf

HTML string to PDF: https://help.syncfusion.com/file-formats/pdf/convert-html-to-pdf/webkit#html-string-to-pdf

 

If you are using HTML string in URL to PDF method, then this exception occurs.

 

//URL to PDF conversion, correct overload
PdfDocument document = htmlConverter.Convert("http://www.google.com");  // This is correct
 
//HTML string to PDF, incorrect overload
PdfDocument document = htmlConverter.Convert(“<html>Hello World</html>”);  
 
//HTML string to PDF, correct overload with base URL. 
PdfDocument document = htmlConverter.Convert(“<html>Hello World</html>”, “”);  //This is correct

 

If the Syncfusion.HtmlConverter.Base.dll assembly is blocked in the machine, then the converter may throw this exception.

Unblock the assembly if it is blocked by referring to the following screenshot of Syncfusion.HtmlConverter.Base.dll,

 

 Assembly unblocking screenshot

This exception may occur if the assemblies and QtBinaries are used from different version of WebKit installers.

Make sure to use the Syncfusion assemblies and QtBinaries from the same WebKit Installer since there will be some changes in the assemblies and QtBinaries for every release. The assemblies and QtBinaries for a specific version can be get by installing the WebKit HTML converter.

WebKit HTML converter: https://www.syncfusion.com/downloads/version-history    

 

While converting HTML to PDF, WebKit HTML converter internally creates temporary files in temp folder for conversion.

 

If the temporary folder does not have elevated permission for the respective user, then the WebKit HTML converter may throw this exception.

By default, WebKit HTML converter gets system temporary folder to create temporary files for conversion. Refer to the following examples of default temporary folder.

 

  • C:\Users\<<username>>\AppData\Local\Temp
  • C:\Windows\Temp

 

Make sure that the previous paths have elevated permission for respective user.

 

(Or)

 

The WebKit HTML converter has support for setting temporary path. Using the TempPath property, you can set any folder path that has read/write/execute permission. Then, the converter uses this path for creating temporary files. Refer to the following code snippet to set temp folder.  

 

WebKitConverterSettings settings = new WebKitConverterSettings();
settings.TempPath = "D://MyProject//bin";

 

If the user has elevated permission, but still getting the failed to convert webpage exception.

 

Please try hosting an application using different user account of the server and check the conversion.

WebKit HTML converter may throw this exception if the Web Application is published in a network shared location.

 

To avoid this exception, publish the application in the server’s local disk, where it will be hosted. Please do not publish the website to shared network location.

If the temporary executables are blocked due to group policy/third party softwares in server.

The temporary executables can be whitelisted in the server using the following ways:

 

  • Set the path of a folder in server as the temporary executables path by setting the TempPath property of WebkitConverterSettings and add that folder’s path in the exception list of group policy/Third Party Software.

 

//Set temporary path to generate temporary files
webkitConverterSettings.TempPath@"C:/HtmlConversion/Temp/";

 

 

 

  • Set a name for the executable in the server by setting the TempFileName property of WebkitConverterSetings and add that name in the exception list of group policy/Third Party Software.

 

//Set temporary file name to generate temporary files 
webkitConverterSettings.TempFileName = "Syncfusion";

 

 

The temporary path may do not have the required (read/write/execute) permission.

 

Enable the read/write/execute permission of the temporary path for the respective group.   

If the failed to convert webpage exception occurs only for particular URL.

 

Please contact Syncfusion support with input HTML, code snippet, and environment details (OS, culture settings, bit version, and more).

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments
Please sign in to leave a comment
Access denied
Access denied