Skip to content

Commit

Permalink
fix: fixed margin issues
Browse files Browse the repository at this point in the history
  • Loading branch information
privateOmega committed May 28, 2020
1 parent c7e29af commit f841b76
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
14 changes: 13 additions & 1 deletion src/docx-document.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@ const landscapeMargins = {
right: 1440,
bottom: 1800,
left: 1440,
header: 720,
footer: 720,
gutter: 0,
};

const portraitMargins = {
top: 1440,
right: 1800,
bottom: 1440,
left: 1800,
header: 720,
footer: 720,
gutter: 0,
};

class DocxDocument {
Expand All @@ -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';
Expand Down
10 changes: 0 additions & 10 deletions template/document.template.js
Original file line number Diff line number Diff line change
@@ -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 `
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
Expand Down

0 comments on commit f841b76

Please sign in to comment.