IronPdf works fine for converting HTML headers and main page but it won't stretch the footer to full width, even though it does for the header and I'm using the same HTML Fragment.
I'm running VS2019, IronPdf 5.2.0.1, C#.
string htmlFooter = "";
using (System.Drawing.Image img = System.Drawing.Image.FromFile(_appPath + @"\Footer01b.png"))
{
using (MemoryStream ms = new MemoryStream())
{
img.Save(ms, img.RawFormat);
byte[] imgB = ms.ToArray();
htmlFooter = Convert.ToBase64String(imgB);
}
}
htmlFooter = "<img style='width:100%' src='data:image/jpeg;base64," + htmlFooter + "'>";
//File.WriteAllText(_appPath + @"\HTML--" + DateTime.Now.ToString("yyyy-MM-dd--HH-mm-ss") + ".html", htmlFooter);
IronPdf.HtmlHeaderFooter ftr = new IronPdf.HtmlHeaderFooter();
ftr.HtmlFragment = htmlFooter;
ftr.Height = 35;
string html = quote.Description;//.Replace("\n", "");
IronPdf.PdfDocument pdf = pdfRend.RenderHtmlAsPdf(html);
pdf.MetaData.Title = title;
pdf.MetaData.Subject = title;
pdf.MetaData.Author = "QuoteMaster - (c) 2017 Mylus Systems LTD.";
pdf.AddHTMLHeaders(ftr);
pdf.AddHTMLFooters(ftr);
pdf.SaveAs(_appPath + @"\HTML--" + DateTime.Now.ToString("yyyy-MM-dd--HH-mm-ss") + ".pdf");
Result:
Have you tried using the AddHTMLHeaders/AddHtmlFooters overload that allows you to specify the margin you would like?
According to the object reference, the AddHTMLHeaders and AddHTMLFooters takes the default margin of 25mm... it's interesting to see that you are having an inconsistency between the default margins of the header and the footer however the overload could help..
https://ironpdf.com/c%23-pdf-documentation/html/M_IronPdf_PdfDocument_AddHTMLHeaders_1.htm https://ironpdf.com/c%23-pdf-documentation/html/M_IronPdf_PdfDocument_AddHTMLFooters_1.htm
pdf.AddHTMLHeaders(ftr, 0, 0, 0);
pdf.AddHTMLFooters(ftr, 0, 0, 0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With