简体   繁体   中英

How to record page numbers html-pdf node.js?

I'm using html-pdf for node.js to create a pdf from html. Built into html-pdf is the ability to add page numbers to the footers. I want to record those page numbers somehow, maybe in an array. This is my current code:

let index = 0;
let myIndex = [];

<div id="pageHeader" style="text-align: center; padding-top: 30px;"></div>
                <body class='page'>      
                    ${myHtmlText} 
                </body>
<div id="pageFooter" style="text-align: center; font-size: 12px;">{{page}}</div>

{{page}} within the pageFooter div automatically increases the page number by 1 each new page. How do I record the value of the page numbers in a variable?

let options = {
            height: '11.25in',
            width: '8.5in',
            header: {
              height: '5mm',
            },
            footer: {
              height: '10mm',
              contents: {
                default:
                  '<div id="pageFooter" style="text-align: center; font-size: 12px;">{{page}}/{{pages}}</div>',
              },
            },
          };

https://www.npmjs.com/package/html-pdf

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM