Convert HTML documents to docx format with header and footer.
npm install html-docx-ts[![NPM version][npm-image]][npm-url]
> Origin html-docx-js ,Rewrite html-docx-js-typescript .
Convert HTML documents to docx format with header and footer.
```
npm install html-docx-ts --save-dev
Support node.js and browser enviroment, including vue/react/angular.
#### Example:
If you want to display page numbers, you can make the string equal to 'pageNum'
`js
import { asBlob } from 'html-docx-ts'
import { saveAs } from 'file-saver' //save the file
function exportDocx() {
//set the config
const HtmlStr =
const option = { orientation: 'portrait', margins: {} }
const headerConfig = {
leftStr: 'headerLeft',
centerStr: 'headerCenter',
rightStr: 'headerRight',
}
const footerConfig = {
leftStr: 'footerLeft',
centerStr: 'footerCenter',
rightStr: 'pageNum',//param equal to 'pageNum', that will show the page numbers
} asBlob(HtmlStr, option, headerConfig, footerConfig).then(blobData => {
saveAs(blobData,
testDocument.docx) // save as docx document
})
}
``MIT
[npm-image]: https://img.shields.io/npm/v/html-docx-ts?color=%23E6F0FD
[npm-url]: https://www.npmjs.com/package/html-docx-ts