php - 如何使用每个页面上的动态内容更新页脚?

标签 php css princexml

在 PrinceXML pdf 中的每个页面中,我们需要根据 php 动态变量更改页脚中的内容。

有没有办法更新每页页脚中的内容?

(下面是css代码和div)

CSS:

@page{ 
    size: US-letter portrait;
    margin: 1in .5in;
    @top{
      content: flow(header);
    }
    @bottom{
      content: flow(footer);
    }
    @bottom-right{
      content: '';
    }
  }
  @page rotated{
    size: US-letter landscape;
  }

  .rotated-page{
    page:rotated;
  }
  /*pagebreaks*/
.page-break{
    page-break-before: always;
  }
.page-break-after{
    page-break-after: always;
  }

/* page_header*/
#header{
    width: 100%;
    flow: static(header,start);
}
.logo-line{
    width:90%;
    margin: 0 auto;
    text-align: center;
}
.page-title{
    font-size: 20px;
    font-family: arial;
    font-weight: bold;
    text-align: center;
    margin: 0;
    padding: 0;
}

/* page_footer*/
#footer{
  width: 100%;
  padding:0;
  border-top: 3px solid #5D1F22;
  flow: static(footer,start);
}

页 footer 分:

<div id="footer">
    <div class='footer-left'>Revision for <?= $this->manual_nm; ?> in <?= $this->revision_cycle; ?> <br>Submission Document printed on <?= $this->generated_date; ?></div>
    <div class='footer-right'></div>
</div>

最佳答案

您可以从页面中提取文本以实现页眉和页脚。

例如,如果我希望最新的 h2 标记出现在页脚中,我可以使用以下 CSS 从标题中提取它。

h2 {
    string-set: title content();
}

名称 title 是您指定的名称 - 例如,您可以将其称为 heading

然后您可以在页脚中使用此字符串:

@page {
    @bottom-left {
        content: string(title);
    }
}

示例改编自 Using CSS Paged Media to Add Dynamic Headers .

关于php - 如何使用每个页面上的动态内容更新页脚?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20355491/

相关文章:

php - 我怎样才能说服我的客户试图隐藏浏览器工具栏是个坏主意?

php - PDO 数组从 MySQL 查询到插入查询

php - 弃用 : preg_replace(): The/e modifier is deprecated in phpmailer

iphone - 在 iPhone/iPad 上查看网站上的 div 之间的空间/间隙

html - 以 `:right` css 页面规则开始第一页?

php - Eloquent/PHP 范围(从/到)

html - 我怎样才能使这个点与文本的基线垂直对齐?

html - 交替换行符上的文本颜色变化?

PrinceXML 带页码的整页背景

javascript - 脚本标签的 src 属性是否应该为 null 或者空字符串?