来自(动态)多页html的pdf,带有页脚和页码

时间:2018-06-29 15:43:18

标签: html css pdf printing nightmare

标题说了我的目标。 我有一张发票,上面有一些基本数据,然后是物品表。最后是footer。我生成了html,并用Nightmare.js

打印

我一切都很好,直到我有很多物品的发票为止。在这种情况下,它将创建一个两页的pdf,其中两个页面(正确)都具有页脚,但内容与页脚重叠。

 #footer {position: fixed; bottom: 0; left: 0; width: 100%; text-align: center}

我尝试通过运行元素来解决问题,但does not work对我来说。

我可以使用page-break-after,但是我不知道何时打破表,因为行的高度可能不同。

还有页码问题。

以下是该问题的演示:enter image description here

和一些 HTML

<div>
  <div class="row">
    <div class="col-sm-12 billing-info clearfix">
      Billing Info
    </div>
  </div>
  <div class="row">
    <div class="col-sm-12">
      <table class="table">
        <thead>
          <th>Description</th>
          <th>Quantity</th>
          <th>Price</th>
        </thead>
        <tbody>
          <% for(var i = 0; i < 20; i++) { %>
            <tr>
              <td>Description</td>
              <td>1</td>
              <td>1000</td>
            </tr>
          <% }%>
        </tbody>
      </table>
    </div>
  </div>
</div>
<div id="footer">FOOTER</div>

CSS 代码:

  #footer {position: fixed; bottom: 0; left: 0; width: 100%; text-align: center}
  .billing-info {
    padding: 20px;
    text-align: center;
    border: 1px solid;
    height: 100mm;
    font-size: 50px
  }
  #footer {
    font-size: 35px;
    height: 15mm;
    border: 1px solid;
    padding: 20px;
  }

0 个答案:

没有答案