我正在尝试自定义页眉和页脚。但我无法将背景颜色添加到页脚。 这就是我正在努力做的事情。
page.pdf({
path: 'test.pdf',
format: 'a4',
landscape: '!data.isPortrait',
footerTemplate: '<div class="footer" style="height:75px;position: absolute;top:auto;left:0px;right:0px;left:0px;background-color:red;">\ </div>',
displayHeaderFooter: true,
margin: {
top: "75px",
bottom: "75px"
}
});
环境
Puppeteer version:1.1.0
Platform / OS version:ubuntu 16.04
Node.js version:8.9
最佳答案
要向页眉/页脚或 Puppeteer 中的页面添加背景颜色,我们需要添加一个额外的 css 属性 -webkit-print-color-adjust:exact
。现在效果很好。
关于node.js - 无法向 pdf 中的页眉/页脚添加背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49257407/