HTML To PDF Converter Setting PDF page size

Hello,

I have an html page in which I set out div width and height to an A4 page size. Such as follows:

<div style="width:21cm; height:29.7cm; border:1px solid red;">Some Content Here...</div>

Now I want to pass this HTML to the Blink HTMLToPDF Converter. When it coverts, I dont seem to get the correct page size produced in the resulting PDF. So question is how do I set the converter page size and/or view port to accurately draw the html page onto an A4 page size in PDF? 

I have tried this:

            blinkConverterSettings.PdfPageSize = PdfPageSize.A4;

and 

            blinkConverterSettings.ViewPortSize = new Syncfusion.Drawing.Size(595, 842); 

What is the correct way of setting the output page dimensions to A4 paper size?

I am working with .NET Core, C#.

Thanks,

Amjad.






1 Reply

SG Sivaram Gunabalan Syncfusion Team November 9, 2021 02:20 PM UTC

Hi Amjad, 
 
We can perform the conversion using provided input HTML string with A4 Page size set to the converter settings and it is have proper A4 page size in output PDF document. The viewport size is only used scaling purpose of the content within the page and it is not used for adjust the page size. We will attach the output document for your reference.  

The chrome print preview of the webpage in browser also have same margin size. 
 

Please let us know if you need further assistance on this. 
 
Regards, 
Sivaram G 



Loader.
Up arrow icon