【问题标题】:Phantomjs:How to remove header footer only for the first page?Phantomjs:如何仅删除第一页的页眉页脚?
【发布时间】:2023-03-18 22:00:01
【问题描述】:

我正在使用 phantomjs 来呈现带有页眉和页脚的 pdf。在所有页面中都实现了添加页眉和页脚。有没有办法单独从第一页删除页眉/页脚?

 header: {
height: "1cm",
contents: phantom.callback(function(pageNum, numPages) {
  return "<h1>Header <span style='float:right'>" + pageNum + " / " + numPages + "</span></h1>";
})},  footer: {
height: "1cm",
contents: phantom.callback(function(pageNum, numPages) {
  return "<h1>Footer <span style='float:right'>" + pageNum + " / " + numPages + "</span></h1>";
})}

【问题讨论】:

    标签: node.js phantomjs


    【解决方案1】:

    虽然不完美,但当 pageNum 等于 1(或在我的情况下为 numPages)时,我返回空字符串而不是实际的 html 内容。高度仍然被占用,但至少是空的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-13
      • 1970-01-01
      • 1970-01-01
      • 2018-07-06
      相关资源
      最近更新 更多