Has anyone been able to dynamically create a header on every single page or a footer with page a current/total page number?
Well... I guess you can.
you have the Methods
So putting them together:
var doc = jsPDF();
doc.setFontSize(12);
doc.addPage();
doc.addPage();
doc.addPage();
doc.addPage();
doc.addPage();
doc.addPage();
var pageCount = doc.internal.getNumberOfPages();
for(i = 0; i < pageCount; i++) {
doc.setPage(i);
doc.text(10,10, doc.internal.getCurrentPageInfo().pageNumber + "/" + pageCount);
}
test it by copy and pasting it here https://parall.ax/products/jspdf
That would not work if say something extends multiple pages. Then your
pageNumber count would be off would it not?
On Tue, Aug 1, 2017 at 5:06 AM, Aras Abbasi notifications@github.com
wrote:
Well... I guess you can.
you have the Methods
- getNumberOfPages
- getCurrentPageInfo which returns an object with the property
pageNumber- setPage
So putting them together:
var doc = jsPDF();
doc.setFontSize(12);
doc.addPage();
doc.addPage();
doc.addPage();
doc.addPage();
doc.addPage();
doc.addPage();
var pageCount = doc.internal.getNumberOfPages();
for(i = 0; i < pageCount; i++) {
doc.setPage(i);
doc.text(10,10, doc.internal.getCurrentPageInfo().pageNumber + "/" + pageCount);
}test it by copy and pasting it here https://parall.ax/products/jspdf
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/MrRio/jsPDF/issues/1340#issuecomment-319313368, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ANmxwUK3W1mqSMTIDKyhNCh7Y5i-yxXbks5sTup6gaJpZM4OXJNA
.
These are API functions. If somebody would modify/extend jspdf with breaking these functions,then it is anyway violating the rules of good coding. And if they would break the functionality the pdf generation would be broken, because the pagenumber is used for it.
I wrote a template plugin.
If you want to see how to use it check the test-file
https://github.com/arasabbasi/jsPDF/blob/plugin/simpleTemplateEngine/tests/template/standard.spec.js
Thanks arasabbasi
Shouldn't these methods show up in the documentation?
Most helpful comment
Well... I guess you can.
you have the Methods
So putting them together:
test it by copy and pasting it here https://parall.ax/products/jspdf