添加经典文本页眉和页脚

学习如何在渲染HTML内容时向PDF文档添加文本页眉和页脚。

要包含文本页眉和页脚,您需要在渲染选项对象中指定它们。 Define the header content with a divider line, centered text displaying the HTML title, font settings, and font size. Similarly, define the footer with the textFooter property. You can utilize fields like {page}, {total-pages}, {url}, {date}, {time}, {html-title}, and {pdf-title} to personalize the content.

自定义边距以适当容纳页眉和页脚。

Utilize the PdfDocument.fromHtml method to convert your HTML content into a PDF. Pass the renderOptions object as an option.

有关从HTML创建PDF的详细文档,请访问IronPDF文档

生成的PDF文档,完整的页眉和页脚,保存在名为"header_footer.pdf"的文件中。

在 GitHub 上探索页眉和页脚示例代码

准备开始了吗?
版本: 2026.3 刚刚发布
Still Scrolling Icon

还在滚动吗?

想快速获得证据?
运行示例看着你的HTML代码变成PDF文件。