I’m using .NET 8, and attempting to render a PDF from HTML using Syncfusions HtmlToPdf Library.
I’m trying to create a footer that displays a blue background all across the bottom page, with no margins (I want the blue to go right up to the bottom, left, and right on every page), and then dropping the page number in the bottom left-hand corner.
The issue I’m running into is that when I use the blinkConverterSettings.HtmlFooter
, it’s rendering the HTML footer perfectly, but it’s lining it up on the bottom of the page offset up by ~20 px from the bottom of the page.
I’ve tried messing around with the .PdfFooter
as well, but I seem to get the exact same behavior. I also can’t see the HTML being rendered on the actual PDF to verify if any extra margins or padding is getting added automatically, but I did try setting all margins, padding, and other whitespace culprits to be 0 and still got a failed result.
var htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();
blinkConverterSettings.Scale = 1.0F;
blinkConverterSettings.ViewPortSize = new Size(1024, 0);
blinkConverterSettings.Margin = new PdfMargins { All = 0 };
blinkConverterSettings.Margin.Bottom = 40;
blinkConverterSettings.HtmlFooter = "<body style="margin:0;"><div style="background-color: blue; -webkit-print-color-adjust: exact; width:100%; height: 40px; font-size: 15px; color:white;"><div style="padding: 10px"><span>Test</span><span class="pageNumber"></span></div></div></body>";
htmlConverter.ConverterSettings = blinkConverterSettings;
PdfDocument document = htmlConverter.Convert("<p>test</p>, "");
1