Search code examples
javascriptc#asp.netpdfsyncfusion

Script File is not executed in PDF file


I am still new to Syncfusion. Currenly I've done a table with a script (document.ready) function to merge the table cells with similar values. The table have been displayed on Google Chrome successfully with my localhost and the columns of the table containing similar values have been merged successfully as well. A function of generating the webpage to PDF works successfully, but the columns of the table displayed on the PDF file do not merge, so I assume that the script file is not rendered in my PDF function.

This is my PDF Function:

    private void printpdf()
    {
       //printpdf
        //Initialize HTML to PDF converter 
        HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
        WebKitConverterSettings settings = new WebKitConverterSettings();
        //Set WebKit path
        settings.WebKitPath = Server.MapPath("~/QtBinaries");
        settings.EnableJavaScript = true;
        settings.AdditionalDelay = 5000;
        //Assign WebKit settings to HTML converter
        htmlConverter.ConverterSettings = settings;
        //Get the current URL
        string url = HttpContext.Current.Request.Url.AbsoluteUri;
        //Convert URL to PDF
        Syncfusion.Pdf.PdfDocument document = htmlConverter.Convert(url);
        //Save the document
        document.Save("Output.pdf", HttpContext.Current.Response, HttpReadType.Save);
    }

This is my Script Function on aspx file:

            $(document).ready(function () {
                -
                -
                -
             };

Solution

  • The webKit rendering engine will preserve the PDF document like how the input HTML file displayed on WebKit (example, safari) based web browsers. So, kindly ensure the preservation of your webpage on WebKit based browser. If it is not possible, kindly share with us the complete HTML file (save the webpage from a web browser and share the complete HTML file with styles, scripts, etc.,) to us. So, that it will be helpful for us to analyze and assist you further on this.

    If your web page is rendering properly in the chrome browser, kindly try our latest Blink rendering engine for the conversion. It will preserve the output PDF document like how the input HTML is displayed on chromium-based browsers. Please refer below link for more information,
    https://help.syncfusion.com/file-formats/pdf/convert-html-to-pdf/blink
    https://www.syncfusion.com/kb/10258/how-to-convert-html-to-pdf-in-azure-using-blink