const {PdfDocument} = require("@ironsoftware/ironpdf");
(async () => {
// Configure render options
const renderOptions = {
firstPageNumber: 1, // Use 2 if a cover page will be appended
// Build a footer using html to style the text
// mergeable fields are:
// {page} {total-pages} {url} {date} {time} {html-title} & {pdf-title}
htmlFooter: {
maxHeight: 15, //millimeters
htmlFragment: "<center><i>{page} of {total-pages}<i></center>",
dividerLine: true,
},
// Build a header using an image asset
htmlHeader: {
maxHeight: 15, //millimeters
htmlFragment: "<img src='logo.png'>",
},
// Use sufficient MarginBottom to ensure that the HtmlFooter does not overlap with the main PDF page content.
margin: {
top: 25, // Create 25mm space for the header
bottom: 25, // Create 25mm space for the footer
},
};
})();
添加HTML页眉和页脚
使用 IronPDF 渲染 PDF 文档时,配置渲染选项以包含 HTML 页眉和页脚,IronPDF 是 Iron Software 的一个库,可实现高级 PDF 生成和操作。