Installations
npm install html-docx-js-typescript-papersize-thenn
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
16.14.2
NPM Version
8.5.0
Score
68.4
Supply Chain
91
Quality
74
Maintenance
100
Vulnerability
99.6
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (99.3%)
JavaScript (0.7%)
Developer
The-Nguyen-Ngoc
Download Statistics
Total Downloads
13,406
Last Day
13
Last Week
67
Last Month
459
Last Year
9,497
GitHub Statistics
2 Stars
4 Commits
1 Watching
1 Branches
1 Contributors
Bundle Size
109.11 kB
Minified
31.55 kB
Minified + Gzipped
Package Meta Information
Latest Version
0.1.5
Package Id
html-docx-js-typescript-papersize-thenn@0.1.5
Unpacked Size
45.29 kB
Size
11.57 kB
File Count
57
NPM Version
8.5.0
Node Version
16.14.2
Total Downloads
Cumulative downloads
Total Downloads
13,406
Last day
-59.4%
13
Compared to previous day
Last week
-43.7%
67
Compared to previous week
Last month
-7.6%
459
Compared to previous month
Last year
156.5%
9,497
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
html-docx-js-typescript
Rewrite html-docx-js with Typescript.
Convert HTML documents to docx format.
Installing
npm install html-docx-js-typescript-papersize-thenn --save-dev
Usage
Support node.js and browser enviroment, including vue/react/angular.
Vue.js usage demo:
1import { asBlob } from 'html-docx-js-typescript-papersize-thenn' 2// if you want to save the docx file, you need import 'file-saver' 3import { saveAs } from 'file-saver' 4 5const htmlString = `<!DOCTYPE html> 6<html lang="en"> 7<head> 8 <meta charset="UTF-8"> 9 <title>Document</title> 10</head> 11<body> 12 <h1>Welcome</h1> 13</body> 14</html>` 15 16export default { 17 methods: { 18 saveDocx() { 19 asBlob(htmlString).then(data => { 20 saveAs(data, 'file.docx') // save as docx file 21 }) // asBlob() return Promise<Blob|Buffer> 22 }, 23 }, 24}
And you can set options including margins and orientation.
1const data = await asBlob(htmlString, { orientation: 'landscape', margins: { top: 100 } })
literal type widen issue
If you use this package in a Typescript file and declare the options to an independent Object
like:
1import { asBlob } from 'html-docx-js-typescript-papersize-thenn' 2const opt = { 3 margin: { 4 top: 100 5 }, 6 orientation: 'landscape' // type error: because typescript automatically widen this type to 'string' but not 'Orient' - 'string literal type', 7 paperWidth: 11905.511, //paper size word * 1440 ( width A4 = 11905.511 ) 8 paperHeight: 16837.795 //paper size word * 1440 ( height A4 = 16837.795 ) 9} 10await asBlob(html, opt)
You can use as const
to avoid type widening.
1const opt = { 2 margin: { 3 top: 100 4 }, 5 orientation: 'landscape' as const 6}
License
MIT
No vulnerabilities found.
No security vulnerabilities found.