elliotblackburn / mdpdf

Markdown to PDF command line app with support for stylesheets
https://npmjs.com/package/mdpdf
Apache License 2.0
712 stars 46 forks source link

How to create a footer with pagination #73

Closed hervehobbes closed 5 years ago

hervehobbes commented 5 years ago

Hello,

Sorry if this question is obvious but I can't find how to create a footer (for example with an html files), that will contains the current page and the total page number, something like this:

Page {{pageNumber}} / {{totalPages}}

For example

Page 1/5

If I write this inside my html footer, it is rendered, in the PDF, as is...

Thanks by advance

elliotblackburn commented 5 years ago

Hi @hervehobbes this is a perfectly valid question. Sadly right now it can't be supported, it used to be when we used Phantom.js to generate our PDF's but since Phantom has been deprecated and development has stopped, we've been forced to move to Chrome Puppeteer. Puppeteer however doesn't support pushing in page numbers into a PDF. It's unspeakably terrible of them but it's what we're left with right now.

I'd really encourage you to open an issue / upvote any existing issues about this on the Puppeteer page because it's really quite a vital component of browsers rendering PDF's.

I'm so sorry we can't support this yet, the moment it's avalible I'll integrate it!

hervehobbes commented 5 years ago

Hello @BlueHatbRit,

Thank you very much for your answer and suggestion.

Bye, Hervé

travs commented 4 years ago

Hey Elliot, was wondering if this is supported now in puppeteer. It looks like it to me, but I can't get page numbers to render when I pass mdpdf something like:

"<div><div class='pageNumber'></div> <div>/</div><div class='totalPages'></div></div>"

Maybe I'm just missing something about how puppeteer works here though.

@BlueHatbRit