We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Removing page borders in HtmlToPdfConverter()

I have a Web page that represents an invoice and captured it with the HtmlToPdfConverter() method.

I would like the Page content to bleed all around the page; however, I am not able to find the settings to set the borders to 0 in the Converter, as I can when I create a PDF from scratch.

Would you please point me to a set of instructions that I can use to change the settings for the generated PDF?

Thank you for your support.

2 Replies 1 reply marked as answer

SN Santhiya Narayanan Syncfusion Team March 15, 2023 02:07 PM UTC

No. We do not have support for removing the page borders from HTML to PDF document. If you want to remove the page margin, we can able to remove by setting the margin as 0.  Please refer to the below code snippet to convert the HTML to PDF without margin, 

//Initialize HTML to PDF converter.

HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();

BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();

blinkConverterSettings.ViewPortSize = new Syncfusion.Drawing.Size(1280, 0);

//Set Blink viewport size.

blinkConverterSettings.Margin.All = 0;

//Assign Blink converter settings to HTML converter.

htmlConverter.ConverterSettings = blinkConverterSettings;

//Convert URL to PDF document.

PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com");

//Create a filestream.

FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite);

//Save and close the PDF document.



Please let us know whether it is satisfies your requirements or not.

Marked as answer

JS Johnny Sandaire March 15, 2023 02:29 PM UTC

This is EXACTLY what I was looking for... Thank You!!!

Live Chat Icon For mobile
Up arrow icon