Skip to content

Commit ca6704b

Browse files
Fix/issue #35 (#37)
* Create npm-publish.yml (#27) * fix: fixed a bug when margin are provided docx is not generated properly * Feature/contributors update (#26) * feat: add contributors * fix: cleanup readme * feat: add banner and updated package.json * chore: fixes and update .gitignore * chore: readme styling * chore: readme refactor styling * chore: add AmitSharma512 as a contributor --------- Co-authored-by: Nicolas <[email protected]> Co-authored-by: nicolasiscoding <[email protected]>
1 parent db5fa73 commit ca6704b

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

.github/workflows/npm-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
node-version: 18
2929
registry-url: https://registry.npmjs.org/
3030
- run: npm ci
31-
- run: npm run build
31+
- run: npm run build
3232
- run: npm publish --access public
3333
env:
3434
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@turbodocx/html-to-docx",
3-
"version": "1.9.4",
3+
"version": "1.9.3",
44
"description": "HTML to DOCX converter",
55
"keywords": [
66
"html",
@@ -41,7 +41,8 @@
4141
"zedtux <[email protected]>",
4242
"hlerebours",
4343
"hakjeri",
44-
"tasola"
44+
"tasola",
45+
"AmitSharma512"
4546
],
4647
"license": "MIT",
4748
"bugs": {

src/docx-document.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,18 @@ class DocxDocument {
124124
this.width = isPortraitOrientation ? width : height;
125125
this.height = isPortraitOrientation ? height : width;
126126

127-
const marginsObject = properties.margins;
128-
this.margins =
129-
// eslint-disable-next-line no-nested-ternary
130-
marginsObject && Object.keys(marginsObject).length
131-
? marginsObject
132-
: isPortraitOrientation
133-
? portraitMargins
134-
: landscapeMargins;
127+
const defaultMargins = isPortraitOrientation ? portraitMargins : landscapeMargins;
128+
const marginsObject = properties.margins || {};
129+
130+
this.margins = {
131+
top: marginsObject.top !== undefined ? marginsObject.top : defaultMargins.top,
132+
right: marginsObject.right !== undefined ? marginsObject.right : defaultMargins.right,
133+
bottom: marginsObject.bottom !== undefined ? marginsObject.bottom : defaultMargins.bottom,
134+
left: marginsObject.left !== undefined ? marginsObject.left : defaultMargins.left,
135+
header: marginsObject.header !== undefined ? marginsObject.header : defaultMargins.header,
136+
footer: marginsObject.footer !== undefined ? marginsObject.footer : defaultMargins.footer,
137+
gutter: marginsObject.gutter !== undefined ? marginsObject.gutter : defaultMargins.gutter,
138+
};
135139

136140
this.availableDocumentSpace = this.width - this.margins.left - this.margins.right;
137141
this.title = properties.title || '';

0 commit comments

Comments
 (0)