dongyashun2559 2013-12-03 15:44
浏览 34

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

In each page inside our PrinceXML pdf we need the content in the footer to change based on a php dynamic variable.

Is there a way to update the content in the footer for each page?

(Below is the css code and the 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:

<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>
  • 写回答

1条回答 默认 最新

  • dongweihuan8832 2013-12-06 14:40
    关注

    You can pull text from the page in order to fulfil the headers and footers.

    For example, if I wanted the latest h2 tag to appear in the footer, I could extract it from the heading using the following CSS.

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

    The name title is a name you give - you could call it heading, for example.

    You can then use this string in your footer:

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

    Example adapted from Using CSS Paged Media to Add Dynamic Headers.

    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP