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 生成和操作。