# html-docx

> html-docx ============

Latest version **1.2.0** (published 2021-08-17) · ISC license · 0 weekly downloads

## Install

```sh
npm install html-docx
pnpm add html-docx
yarn add html-docx
bun add html-docx
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2021-08-17 |
| First published | 2019-10-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 479 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | xueqingcheng |
| Keywords | html, html-docx, htmlToWord, word, html2word, docx, doc |

## Links

- npm: https://www.npmjs.com/package/html-docx
- npm.io page: https://npm.io/package/html-docx

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 1.2.0 (latest) — 2021-08-17
- 1.1.20 — 2020-12-02
- 1.1.2 — 2020-07-31
- 1.1.1 — 2020-07-31
- 1.1.0 — 2020-07-31
- 1.0.16 — 2020-01-20
- 1.0.15 — 2020-01-20
- 1.0.14 — 2020-01-20
- 1.0.13 — 2020-01-20
- 1.0.12 — 2020-01-20
- 1.0.11 — 2020-01-20
- 1.0.10 — 2020-01-20
- 1.0.8 — 2019-10-30
- 1.0.7 — 2019-10-30
- 1.0.6 — 2019-10-30
- … 6 more at https://npm.io/package/html-docx/versions

## README

html-docx
============

this is a simple library to convert html to docx,it is based on the [html-doxc-js](https://github.com/evidenceprime/html-docx-js)

useage
-------------
#### Usage and demo
```
yarn add html-docx   npm i html-docx --save   cnpm i html-docx --save

import HtmlToDocx from 'html-docx'
HtmlToDocx({
    exportElement: '#html-content', // 需要转换为word的html标签
    exportFileName: 'list.docx', // 转换之后word文档的文件名称
    StringStyle: '', // css样式以字符串的形式插入进去
    margins:{top: 1440,right: 1440,bottom: 1440,left: 1440,header: 720,footer: 720} // word的边距配置
})
```
#### use in-inline in html
[you can use it refer to the example useage](https://github.com/forever-chen/html-docx/blob/master/test/sample.html)

Compatibility
------------

This library should work on any modern browser that supports `Blobs` (either natively or via
[Blob.js](https://github.com/eligrey/Blob.js/)). It was tested on Google Chrome 36, Safari 7 and
Internet Explorer 10.

Images Support
------------

* images/cavans is supported in the library
the src of images can be URI or inlined base64(图片不要太大，因为图片会以base64的格式插入进去)
* cavans can be generate by common charts library or protogenetic(cavans图表也支持)


API
------------
##### `<div id="html-docx-config">`
* 这个元素内部设置元素docx文档的配置信息（具体设置可以到sample例子中看）
##### `<div id="page-header" textAlign='right'>我的新世界</div>` 
* 这个元素内部文字设置为文档的页眉
* textAlign设置文字居中格式
##### `<div id="first-page" titlePg='false'><div style='text-align: center;'>dfsdfsdf</div></div> `
* 这个标签内的元素设置为文档的封面
* 这里不会有页眉、页脚、
* 这里不能有h标签
#### `<div id="page-content"></div>`
* 如果需要目录则添加这个元素，不需要目录就不需要添加这个元素
#### `<div class="change-line"></div>`
* 这个元素用来开启新的页面，在需要开启新页面的地方直接添加这个元素即可
#### `<div id="page-footer"></div>`
* 这里设置页脚，目前只支持页码
#### <div id="html-content">
* 这个元素内部设置需要转换的html内容
* 页面中需要加入目录的标题需要使用h标签来定义
#### 详细使用例子可以到sample.html中查看
reminder
-------------
**all classNames or Id of elements in API cannot be changed(上述api中提供的id都不能随便修改)**

### [you can push issues to](https://github.com/forever-chen/html-docx/pulls) 

License
-------

Copyright (c) 2015 Evidence Prime, Inc.
See the LICENSE file for license rights and limitations (MIT).

---
_Source: https://npm.io/package/html-docx · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
