Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom header and footer to generated pdf #26

Open
valterbarros opened this issue Feb 21, 2019 · 1 comment
Open

Add custom header and footer to generated pdf #26

valterbarros opened this issue Feb 21, 2019 · 1 comment

Comments

@valterbarros
Copy link

I see that htmlpdfchrome has this option with:

const pdf = await htmlPdf.create(html, {
  port,
  printOptions: {
    displayHeaderFooter: true,
    headerTemplate: `
      <div class="text center">
        Page <span class="pageNumber"></span> of <span class="totalPages"></span>
      </div>
    `,
    footerTemplate: '<div class="text center">Custom footer!</div>',
  },
});

Can I do this on pdf-bot generation?

@xucito
Copy link

xucito commented Sep 23, 2019

You can just pass printOptions directly to generator section. i.e.

var htmlPdf = require('html-pdf-chrome')

module.exports = {
  api: {
    token: 'api-token'
  },
  // html-pdf-chrome options
  generator: {
    completionTrigger: new htmlPdf.CompletionTrigger.Timer(5000), // waits for 5 sec,
    printOptions: {
       displayHeaderFooter: true,
       headerTemplate: `
			<div class="text center">
				Page <span class="pageNumber"></span> of <span class="totalPages"></span>
			</div>
    	`,
    footerTemplate: '<div class="text center">Custom footer!</div>',
  }
  },
  webhook: {
    secret: '1234',
    url: 'http://localhost:3000/webhooks/pdf'
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants