diff --git a/src/docx-document.js b/src/docx-document.js index c4ef896b..439446c4 100644 --- a/src/docx-document.js +++ b/src/docx-document.js @@ -16,6 +16,9 @@ const landscapeMargins = { right: 1440, bottom: 1800, left: 1440, + header: 720, + footer: 720, + gutter: 0, }; const portraitMargins = { @@ -23,6 +26,9 @@ const portraitMargins = { right: 1800, bottom: 1440, left: 1800, + header: 720, + footer: 720, + gutter: 0, }; class DocxDocument { @@ -46,7 +52,13 @@ class DocxDocument { this.orientation = orientation; this.width = orientation === 'landscape' ? 15840 : 12240; this.height = orientation === 'landscape' ? 12240 : 15840; - this.margins = margins || orientation === 'landscape' ? landscapeMargins : portraitMargins; + this.margins = + // eslint-disable-next-line no-nested-ternary + margins && Object.keys(margins).length + ? margins + : orientation === 'landscape' + ? landscapeMargins + : portraitMargins; this.title = title || ''; this.subject = subject || ''; this.creator = creator || 'html-to-docx'; diff --git a/template/document.template.js b/template/document.template.js index 78a2bc55..81e86880 100644 --- a/template/document.template.js +++ b/template/document.template.js @@ -1,13 +1,3 @@ -export const defaultMargins = { - top: 1440, - right: 1440, - bottom: 1440, - left: 1440, - header: 720, - footer: 720, - gutter: 0, -}; - const generateDocumentTemplate = (width, height, orientation, margins) => { return `