You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const fs = require('fs');
const docx = require('docx');
const { Document, Packer, Paragraph, Footer, TextRun, PageBreak, PageNumber, NumberFormat } = docx;
const doc = new Document({
sections: [
{
properties: {
page: {
pageNumbers: { start: 1, formatType: NumberFormat.DECIMAL },
},
},
footers: {
default: new Footer({
children: [
new Paragraph({
text: PageNumber.CURRENT + ' of ' + PageNumber.TOTAL_PAGES
}),
]
}),
},
children: [
new Paragraph({
children: [
new TextRun('text on page 1'),
new PageBreak(),
new TextRun('text on page 2'),
new PageBreak(),
new TextRun('text on page 3')
]
})
]
}
]
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync('doc.docx', buffer);
});
Hi!
I followed the readme to get page numbers, but the code above returns only a footer line saying "CURRENT of TOTAL_PAGES".
What am I doing wrong?
Thanks!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
I followed the readme to get page numbers, but the code above returns only a footer line saying "CURRENT of TOTAL_PAGES".
What am I doing wrong?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions