Skip to content
This repository was archived by the owner on Mar 7, 2024. It is now read-only.

Latest commit

 

History

History
68 lines (56 loc) · 1.06 KB

headers-footers.md

File metadata and controls

68 lines (56 loc) · 1.06 KB

Headers and Footers

Adding headers and footer to each page is easy! Simple add a header and/or footer chunk to your render options, and it will be automatically added.

The header and footer content can be in any format that templateSource accepts (except a remote URL).

Example

const renderer = new Renderer({ dirname: __dirname });

// main template
const templateSource = `
<div class='Page'>
  My page 1 content here
</div>

<div class='Page'>
  My page 2 content here
</div>
`

// Headers
const header = `
<div class='header'>
  PDFTron.com
</div>
`

// Footers
const footer = `
<div class='footer'>
  Footer
</div>
`

renderer.render({
  templateSource: html,
  chunks: {
    header,
    footer
  }
});

Output

<div class='Page'>
  <div class='header'>
    PDFTron.com
  </div>
  My page 1 content here
  <div class='footer'>
    Footer
  </div>
</div>

<div class='Page'>
  <div class='header'>
    PDFTron.com
  </div>
  My page 2 content here
  <div class='footer'>
    Footer
  </div>
</div>