The default header distance from top is 1.25cm. My task requires it to be tinier. I couldn't find anything in manual nor in templates. Does such function exist?
We can change header and footer distance in addSection
doc.addSection({
margins: {
header: 400, //header distance from top
footer: 400, //footer distance
},
});
The default header distance from top is 1.25cm. My task requires it to be tinier. I couldn't find anything in manual nor in templates. Does such function exist?
I found a solution. Do it like the code below. 馃槃
You can ignore that function calculateMargin cuz I made it for easy coding.
doc.addSection({
margins: {
top: this.calculateMargin(3.06),
right: this.calculateMargin(2.2),
bottom: this.calculateMargin(2.5),
left: this.calculateMargin(2.2),
header: this.calculateMargin(1.5),
},
...
});
...
calculateMargin(cm) {
return Math.floor(cm / 2.54 * 72 * 20);
}
Side Remark: I think it would be cool to include these "convenience functions". Likely everyone is implementing them 馃槅 at some point.

Great idea @thojansen! Created a PR to add Convenience functions into docx
super cool !!!
Most helpful comment
Side Remark: I think it would be cool to include these "convenience functions". Likely everyone is implementing them 馃槅 at some point.