-
-
Notifications
You must be signed in to change notification settings - Fork 484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent default Header creation #251
Comments
Yes correct, it creates a header and footer by default What is the use-case for not creating a default header/footer? Can you explain |
Because the default header has margin, and even if I left the header empty, the printed file has extra margin. |
Ah yes, you have a good point there I will think of a solution for v5 |
Can you suggest how to set the header margin to 0 ? I am creating a document with no header or footer and I don't want the extra margin on the document. |
@Mitiryl how do you overwrite default header style? |
Workaround for this issue is set 'headers' and 'footers' in margins to null, in this way: import * as fs from 'fs'
import { Document, TextRun, Paragraph, Packer } from 'docx'
const doc = new Document()
doc.addSection({
margins: {
top: 0,
right: 0,
bottom: 0,
left: 0,
headers: null,
footers: null
},
children: [
new Paragraph({
children: [
new TextRun('Hello World')
]
})
]
})
Packer.toBuffer(doc)
.then(buffer => {
fs.writeFileSync('My Document.docx', buffer)
}) |
@arthurstelmach Thanks for your trick. Very usefull. |
default headers are now undefined by default starting from version Fixed by: #829 |
#251 Turning off default headers by default
Hi!
Using your library, we find out that it creates by default a header unless a template with headers array is specified.
Maybe could be possible to create the document without the default header (and also default footer) or add an option to remove it?
Thanks
The text was updated successfully, but these errors were encountered: