I'm digging through the code but cannot seem to find how to configure the default page setup for printing:

docx seems to have a default of A4, but I am trying to set it to US Letter format. Do you know where I can configure this programmatically?
I think this is different from page margins (e.g. https://github.com/dolanmiu/docx/issues/50) but could be wrong.
It looks the pgSz in word/document.xml controls this setting:
<sectPr rsidR="0091789E" rsidSect="00A53414">
<headerReference type="default" id="rId17"/>
<footerReference type="default" id="rId18"/>
<pgSz w="12240" h="15840"/>
<pgMar top="1440" right="714" bottom="1252" left="714" header="708" footer="708" gutter="0"/>
<cols space="708"/>
<docGrid linePitch="360"/>
</sectPr>
I would be interested in setting this programmatically once for the entire document.
There is the Page Size function, but I can't seem to get it to work and haven't found any examples of its use.
@LSchaming I think you can control it when you initialize the document:
const doc = new docx.Document(
{
title: 'my document',
},
{
right: 714,
bottom: 1252,
left: 714
}
);
The second argument above is a ipagemarginattributes object. You may have to explore the definitions a bit more to fine tune those options (using visual studio code to jump to definitions). Nonetheless, I think better documentation is needed.
@dolanmiu Any help on this?
There's still no support for entire page margins, and the documentation isn't clear about that
This is how I create a US Letter sized page in landscape with small margins using [email protected]:
const doc = new docx.Document();
doc.addSection({
size: {
width: 12240, // width and height transposed in LANDSCAPE
height: 15840,
orientation: docx.PageOrientation.LANDSCAPE
},
margins: {
top: 720,
right: 720,
bottom: 720,
left: 720
},
children: [new docx.Paragraph('some text')]
});
Units in Word are often in DXAs
Most helpful comment
It looks the
pgSzinword/document.xmlcontrols this setting:I would be interested in setting this programmatically once for the entire document.