使用Iron PDF将HTML转换为PDF时未出现边框



我正试图使用Iron PDF将HTML文档转换为PDF,用于每页(顶部和底部(的边框,但边框仅在第一页和最后一页生成。我试过参考谷歌,但仍然没有成功。

有什么解决方案吗

我们使用IronPDF。NET应用程序开发。它与Chrome浏览器自2021年9月以来的确切行为非常吻合,这产生了巨大的差异。

本教程帮助我调试了html。

  • https://ironpdf.com/tutorials/pixel-perfect-html-to-pdf/

另一种方法是在每个页面上使用HTML页眉/页脚来实现这一点。截至2021.9 Ironpdf,您甚至可能拥有HTML页眉和页脚以及同一页面上基于文本的页眉和页脚:https://ironpdf.com/examples/html-headers-and-footers/

// PM> Install-Package IronPdf
using IronPdf;

IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();

// Build a footer using html to style the text
// mergeable fields are:
// {page} {total-pages} {url} {date} {time} {html-title} & {pdf-title}
Renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter()
{

HtmlFragment = "<center><i>{page} of {total-pages}<i></center><hr/>",
DrawDividerLine = true
};
Renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter()
{

HtmlFragment = "<hr/><b>Footer (C)2021 Steph the Honey Badger<b>",
DrawDividerLine = true
};

最新更新