Can I use Syncfusion as ASP code (not ASP.net) to convert html to pdf?

Hi, Our systems haven’t gotten to ASP.Net yet, only use ASP. Can SyncFusion engine be called by ASP? If so, do you have document and sample codes like following ASP format?

Set oPDF  = CreateObject("SyncFusion.Doc")

oPDF.Page = oPDF.AddPage()

oID = oPDF.AddImageHtml(sHTML)

......

oPDF.Save sFileName

Thanks,


18 Replies 1 reply marked as answer

GK Gowthamraj Kumar Syncfusion Team September 23, 2020 12:09 PM UTC

Hi Yong, 

Thank you for your update. 
 
Syncfusion HTML to PDF converter is a .NET library for converting web pages, SVG, MHTML and HTML files to PDF using C#. It uses popular rendering engines such as Internet Explorer (IE), WebKit, and Blink (Google Chrome). It is reliable and accurate. The result preserves all graphics, images, texts, fonts, and the layout of the original HTML document or webpage.  

Kindly please provide more details about your requirement (ASP code files, complete sample, you are mentioned the ASP code in your input html file or somewhat) to check in our end. So, that it will be helpful for us to analyze and assist you further on this. 

Regards, 
Gowthamraj K 



YS Yong Su September 23, 2020 03:03 PM UTC

Hi, Gowthamraj,

Our current web application server side code is written by ASP code, not ASP.net, C#, or VB.net. We already has the html data. We need Syncfusion library to convert html to pdf. When loading the library, we cannot use C# code or ASP.net code like: using Syncfusion.Pdf; using Syncfusion.HtmlConverter; And we cannot use VB.net code like: Imports Syncfusion.Pdf ; Imports Syncfusion.HtmlConverter. etc.

Our question is: Can SyncFusion library be called by the ASP code. ASP code usually has following format to load library, for example:

Set oPDF  = CreateObject("SyncFusionXX.doc")
oPDF.Page = oPDF.AddPage()
oID = oPDF.AddImageHtml(sHTML)
......
oPDF.Save sFileName

We currently evaluate several pdf products to replace our current one. If the product can be called from ASP code, then it can be implemented easily to our infrastructure with minimum code changes. Thanks.



GK Gowthamraj Kumar Syncfusion Team September 24, 2020 12:54 PM UTC

Hi Yong, 

Thank you for your update. 

As we said earlier, Syncfusion HTML to PDF converter is a .NET library for converting web pages, SVG, MHTML and HTML files to PDF using C#. It uses popular rendering engines such as Internet Explorer (IE), WebKit, and Blink (Google Chrome). It is reliable and accurate. The result preserves all graphics, images, texts, fonts, and the layout of the original HTML document or webpage. Our library is support in frameworks for WinForms, WPF, ASP.NET (Web Forms, MVC, Core), UWP, Xamarin. Currently, our Syncfusion product is not supported in ASP code. 
 
Please refer the below links for more information Syncfusion library, 

Please let us know if you need any further assistance with this. 

Regards, 
Gowthamraj K 



YS Yong Su September 24, 2020 02:24 PM UTC

Thank you for verification that Syncfusion doesn’t support the classic ASP code. In order for our asp code to call the .net object, we need the .net library has the COM-visible assembly. Does the Syncfusion .Net library has the COM-visible Assembly?



AR Asim Riaz September 24, 2020 06:48 PM UTC

  • The Itext7 could convert the html form codes to PDF. I suggest you could try to use Trafoos Itext7 's Html2pdf library to achieve your requirement. Notice:You should firstly read the generated MVC page as html and send to MVC action, then you could use Itext7 's Html2pdf library to convert html form to PDF.



  • AR Asim Riaz September 24, 2020 06:50 PM UTC

     i am also facing the same issue on my site.


    PN Preethi Nesakkan Gnanadurai Syncfusion Team September 25, 2020 04:22 AM UTC

    From: Yong Su Sent: Thursday, September 24, 2020 10:24 AM
    To: Syncfusion Support <[email protected]>
    Subject: RE: Syncfusion support community forum 158076, Can I use Syncfusion as ASP code (not ASP.net) to convert html to pdf?, has been updated. 


    Thank you for verification that Syncfusion doesn’t support the classic ASP code. In order for our asp code to call the .net object, we need the .net library has the COM-visible assembly. Does the Syncfusion .Net library has the COM-visible Assembly? 
     
    Yong Su 
    Descartes Systems Group 



    GK Gowthamraj Kumar Syncfusion Team September 25, 2020 12:54 PM UTC

    Hi Yong, 

    Thank you for your update. 

    No. Syncfusion .Net library is not a COM-visible library. And we could not convert the ASP code to HTML file/string in our end. Our Syncfusion product is a .Net library, it is used for converting the HTML file/URL to PDF. We have to provide the input HTML to our converter for performing PDF operation. Its preserves the output PDF document like how the input HTML file/URL is displayed on the browsers. 

    Regards, 
    Gowthamraj K 



    YS Yong Su October 29, 2020 12:50 AM UTC

    Hi, I just followed up on this issue. I just created Com+ visible wrapper, and installed the SyncFusion whole version on my machine. When I run your example as following trying to convert html string to pdf, and get error: "Syncfusion.Pdf.PdfException: WebKit assemblies are missing at C:/QtBinaries/ at ....

    My question: I installed the whole package, why did it still complain that WebKit assemblies are missing. Where can I get the WebKit assemblies?

    //Initialize HTML to PDF converter 
    HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);

    WebKitConverterSettings settings = new WebKitConverterSettings();

    //HTML string and Base URL 
    string htmlText = "<html><body><img src=\"syncfusion_logo.gif\" alt=\"Syncfusion_logo\" width=\"200\" height=\"70\"><p> Hello World</p></body></html>";

    string baseUrl = @"C:/Temp/HTMLFiles/";

    //Set WebKit path
    settings.WebKitPath = @"/QtBinaries/";

    //Assign WebKit settings to HTML converter
    htmlConverter.ConverterSettings = settings;

    //Convert HTML string to PDF
    PdfDocument document = htmlConverter.Convert(htmlText, baseUrl);

    //Save and close the PDF document 
    document.Save("Output.pdf");


    GK Gowthamraj Kumar Syncfusion Team October 29, 2020 12:36 PM UTC

    Hi Yong, 

    WebKit assemblies missing exception may occur, if the QtBinaries folder is not present in the provided WebKitPath. So, please make sure that, you have provided proper WebKitPath and the provided WebKitPath should have all the QtBinaries assemblies. You can copy the QtBinaries folder from HTML converter installed location to your project folder. Then you can get the folder path and set it to the WebKitPath property of WebKitConverterSettings.  

    Please refer to this below HTML converter installer location for QtBinaries folder, 
    Location: $system drive:\Program Files (x86)\Syncfusion\HTMLConverter \{Version}\QtBinaries 
     
    Refer below links for prerequisites and troubleshooting WebKit HTML converter,  

    Please let us know if you need any further assistance with this. 

    Regards, 
    Gowthamraj K 



    YS Yong Su November 2, 2020 11:58 PM UTC

    Hi,

    Just follow up on the issue. When I try to use Syncfusion.HtmlConverter.Base to convert html to pdf, I got following error. Can you tell me what the error CreateProcessAsUser means? Thanks,




    GK Gowthamraj Kumar Syncfusion Team November 3, 2020 12:03 PM UTC

    Hi Yong, 

    The reported exception might occur due to the following causes, please try the below trouble shooting steps and try the conversion. 

    1. Our 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. So, please check the temporary folder has read/write/execute permission for the respective user group.
     
    1. If we do not explicitly set TempPath in WebKitConverterSettings then the converter will make use of system temporary folder for creating temporary files. So, please make sure the provided temporary folder has the required permission.
     
    1. This exception may occurs 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)
     
    1. Make sure that you are using Syncfusion assemblies and QtBinaries from same version of HTML converter installer or NuGet package.
     
    1. Check the Syncfusion.HtmlConverter.Base.dll is blocked or not, if it is blocked please try the conversion after unblock it. Please refer below link for more information.
     
    Also, please make sure the mentioned prerequisites are available in the machine where the conversion take place.   

    We have attached a simple sample, which is working fine in our end. Please try the sample in your machine and let us know the result. 

    Please try the above suggestions in your end and let us know the result. 

    Regards, 
    Gowthamraj K 



    YS Yong Su November 3, 2020 04:54 PM UTC

    Thank you, Gowthamraj. We are getting close. I have a question about the package size issue. Basically, the only function we need is to convert html string to pdf. We only need to add two dll files: Syncfusion.Pdf.Base.dll, Syncfusion.HtmlConverter.Base.dll to our project reference. So on our development environment, we installed the Syncfusion studio, only add asp.net, mvc parts, which will occupy 3+ GB plus QtBinaries folder about 600 MB. After the development is done, do you have the small package with only needed dll files for the production servers? Thanks.


    GK Gowthamraj Kumar Syncfusion Team November 4, 2020 02:09 PM UTC

    Hi Yong, 

    Thank you for your update. 

    You can directly install the HTML Converter NuGet package in your development and production environment instead of installing the Syncfusion studio. You can get the required assemblies and QtBinaries folder from the HTML Converter NuGet package installed location for converting HTML to PDF conversion. The size of the QtBinaries folder is 60MB and all the files from inside the QtBinaries folder are needed for conversion.  

    Please refer the NuGet link from below, 

    Please let us know if you need any further assistance with this.  

    Regards, 
    Gowthamraj K 



    YS Yong Su November 9, 2020 08:00 PM UTC

    Hi, Gowthamraj,

    How to install the *.nupkg file without using the Visual Studio? I just uninstalled the whole Syncfusion Studio package from one machine and try to install the nupkg you just mentioned. But After I uninstalled everything, but keep Syncfusion.HtmlConverter.Base.dll, Syncfusion.pdf.dll in my bin drive, my com+ API still works converting html to pdf. Does this mean that I don't have to install the *.nupkg, instead, copy required dll files from one machine to another? 


    GK Gowthamraj Kumar Syncfusion Team November 10, 2020 01:09 PM UTC

    Hi Yong, 

    Yes. You can copy and paste the required assemblies and QtBinaries folder to one machine to another machine, it will works properly. Please make sure that you are using Syncfusion assemblies and QtBinaries from same version of HTML converter installer or NuGet package.  

    Also, please make sure the mentioned prerequisites are available in the machine where the conversion take place.    

    Note: You can extract the .nupkg file in your machine and get the assemblies and QtBinaries folder. 
       
    Regards, 
    Gowthamraj K 



    PN Preethi Nesakkan Gnanadurai Syncfusion Team November 12, 2020 05:09 AM UTC

    From: Yong Su  
    Sent: Wednesday, November 11, 2020 3:02 PM
    To: Syncfusion Support <[email protected]>
    Subject: RE: Syncfusion support community forum 158076, Can I use Syncfusion as ASP code (not ASP.net) to convert html to pdf?, has been updated. 

    Hi, Gowthamraj, 
     
    We currently use Syncfusion Webkit method to convert html to pdf. I am attaching both input html string and output pdf result. Here is the problem: 
     
    • The Banner.gif icon at the header is not converted;
    • Some of the line alignments are not correct;
    • PRINT and CLOSE button on the top right are inactive. But for the html input, both buttons works fine.
     
    So what went wrong?  
    Thanks, 
     
    Yong Su 



    GK Gowthamraj Kumar Syncfusion Team November 13, 2020 01:37 PM UTC

    Hi Yong, 

    Thank you for your patience. 

    On further analysis, we suspect that the baseURL is in HTTPS format, so that the baseURL was not able to find the resources (such as images, scripts, styles) of the HTML file. While accessing the HTTPS resources, WebKit HTML converter requires OPENSSL libraries to be installed in the machine. So, please make sure the OPENSSL assemblies are available in the machine where the conversion takes place. If it is not available, OPENSSL assemblies can be placed in the Windows system folder of the machine and try the conversion in your project and let us know the result.  

    Refer below UG links for more information, 

    Please find the code snippet to enable the valid formatted form field,  
    //Set Enable form 
    settings.EnableForm = true; 

    Please refer to this below UG links for more information, 
     
    Please refer to this below links for preserving resources (CSS/Images/Scripts etc.,) about HTML string to PDF conversion.   

    If still you are facing the same issue, kindly provide us the complete HTML file with baseURL (all the resources such as images, scripts, styles), code snippet to reproduce the issue in our end. So, that it will be helpful for us to analyze and provide you the solution at the earliest.  

    Regards, 
    Gowthamraj K 


    Marked as answer
    Loader.
    Up arrow icon