pofider / phantom-html-to-pdf

Highly scalable html to pdf conversion using phantom workers
MIT License
159 stars 33 forks source link

How to reset pageNum? How to achieve mass PDF generation #66

Closed kalius closed 7 years ago

kalius commented 7 years ago

Hi,

I am wondering if it is possible to reset {#pageNum} variable in footer? There is requirement for mass PDF generation and that includes page numbering. So everytime there is content for new PDF, pageNum should be reset to 1. That would be convenient for printing large number of PDFs (so all PDF will be in one file).

Is there any option for that? What about merging PDFs with that library?

Thank you for any answer.

bjrmatos commented 7 years ago

What about merging PDFs with that library?

we don't have a good solution for merging PDF yet, but it is on our radar, but if we figure out something it would probably not be part of this package.

I am wondering if it is possible to reset {#pageNum} variable in footer?

since phantomjs does not have any native way to do that, it is not possible.

There is requirement for mass PDF generation and that includes page numbering. So everytime there is content for new PDF, pageNum should be reset to 1.

hmm i think that you can achieve that using some logic inside the footer and if you have some things in place, put some javascript that subtracts the number of the new page number with the pageNum of the last page of your first block content, you will need to know where content in your PDF ends and starts, i don't know a good way to do that and it depends on your content but you will need to try on your own.

kalius commented 7 years ago

Ok, thanks.

Your last suggestion would be good if number of pages is known prior generation, but sadly it isn't... I will try some other solution for merging then. Thanks anyway!