How to convert Xhtml File to PDF via Syncfusion html to pdf conversion

I have xhtml file that is loaded by javascript, i want to convert that file into PDF. 

I have Html to PDF conversion license from Syncfusion. 

When i use BlinkSettings as waitforstatus = "ready" or "completed" the whole thing is stuck.

When i use additionalDelay or enablejavascript, the generated PDF is stuck at loading animation of the xhtml

the xhtml file contains only template html all the data is appeneded into javascript  and is loaded via javascript function, when the page is loaded. All the dependencies are built inside the page, there is no external dependencies for this xhtml




10 Replies

BA bala September 18, 2025 01:25 AM UTC

attached a zip containing xhtml for reference


Attachment: testpdf_a9f02e30.zip


KS Karmegam Seerangan Syncfusion Team September 18, 2025 09:25 AM UTC

Hi Bala,

 

Thank you for reaching out to Syncfusion Support. We are able to reproduce the reported issue on our end. Currently, we are validating this issue and will update with further details on 22nd September 2025.

 

Regards,

Karmegam



KS Karmegam Seerangan Syncfusion Team September 22, 2025 12:58 PM UTC

Hi Bala,

Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property. This feature requires changes in the HTML file.


Kindly add the below script code to your HTML file. Once the window's status value is assigned, the PDF conversion will proceed.

</script>

    <script>

        function checkPageLoaded() {

            return new Promise((resolve) => {

                window.addEventListener('load', function () {

                    console.log('All content is fully loaded');

                    this.window.status='ready';

                });

            });

        }   

        checkPageLoaded().then((status) => {

            console.log('Page status:', status);

          

        });

 

    </script>


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/HtmlToPDF_WindowStatus


Documentation: HTML to PDF converter features in .NET PDF Library | Syncfusion

Kindly try the provided sample on your end and let us know the result.


Note: If the window status does not match in code and HTML, then the converter will meet with a deadlock.


Regards,
Karmegam



BA bala September 25, 2025 06:37 AM UTC

Hi 

Thanks for the reply, when i tried with a larger document, it got stuck, attached a zip file for your reference.


Attachment: myxhtml_52caa40d.zip


KS Karmegam Seerangan Syncfusion Team September 26, 2025 02:06 PM UTC

Hi Bala,


We are able to reproduce the reported issue on our end. Currently, we are validating this issue and will update with further details on October 1st, 2025.


Regards,

Karmegam



KS Karmegam Seerangan Syncfusion Team October 1, 2025 04:32 PM UTC

Hi Bala,

Due to the complex JavaScript and extended loading time, the reported issue occurred. We can resolve this by setting a time delay to allow the JavaScript to load properly. Please refer to the sample JavaScript code provided below.

We have also attached a sample and code snippet for your reference.

function checkPageLoaded() {

            return new Promise((resolve) => {

                window.addEventListener('load', function () {

                    console.log('All content is fully loaded');

                    setTimeout(function () { this.window.status = 'ready'; },5000 )    

                });

            });

        }  

        checkPageLoaded().then((status) => {

            console.log('Page status:', status);

        });


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/HtmlToPDF_WindowStatus

Kindly try the sample and let us know the results.


Regards,
Karmegam



BA bala October 7, 2025 05:59 AM UTC

Hi Karmegam,


after running the sample i can see the output PDF has only one page, the html file spans 91 pages, but from the code sample, gives me only one page PDF, am i missing something here, while running the sample code.


The above sample when run in Linux Docker environment, still hangs the process


Edit: Do i need to blink converter settings "enable javascript " to true?

Bala



KS Karmegam Seerangan Syncfusion Team October 7, 2025 03:56 PM UTC

Hi Bala,


Our HTML Converter internally uses the Blink rendering engine, which utilizes the Chromium headless browser to convert HTML to PDF documents. The output PDF document is preserved exactly as the input HTML appears in Chrome's print preview.

 

Upon further analysis, the provided input HTML file displays only two pages in Chrome's print preview itself. The same result will be replicated by our converter. If you are facing any rendering issues, kindly check your input HTML file and verify it using Chrome's print preview.

 

image

 

When assigning a value to the WindowStatus property, the input HTML page or URL must return a window status value that matches the assigned value. If this condition is not met, the conversion may hang. However, we support setting a timeout value in the Blink converter settings. Please refer to the documentation below.

 

HTML to PDF converter features in .NET PDF Library | Syncfusion


Regards,
Karmegam



BA bala October 16, 2025 11:27 AM UTC

i have one more question, when i tried convert htm file into PDF the css in the table are not rendering properly


Image_4002_1760613833139

the above is a screenshot from the html, the red bars are distinct in the cells and rows, making it readable

The below is screenshot from converted PDF using syncfusion, see the second column, the red bar is moving into the text making it unreadable, how do i fix it? Attached a htm zip file for your reference.




Image_5437_1760613915390


T


Attachment: markedPdf_b52f814c.zip


AM Arumugam Muppidathi Syncfusion Team October 17, 2025 01:33 PM UTC

Hi Bala,


We have reviewed the reported issue on our end. Upon further analysis, we were able to replicate the problem. The output PDF document contains red lines that obscure the text, making it unreadable.

 

Our HTML converter uses the Blink rendering engine, which relies on the Chromium headless browser. This engine renders the PDF output to closely match how the input HTML appears in Chrome’s print preview. We tested the provided HTML document directly in Chrome’s print preview and observed the same issue there. Please refer to the screenshot below for reference.

 

undefined

 

Since this behavior is consistent with Chrome’s rendering, we are unable to proceed further from our side. We recommend verifying whether the issue is visible in Chrome’s print preview. If it is, the same behavior will be reflected in the output PDF document generated by our converter.

 

Please review this information on your end and let us know your findings. Feel free to reach out if you need any further assistance.


Regards,
Arumugam M


Loader.
Up arrow icon