1.2.0 • Published 3 years ago

html-docx v1.2.0

Weekly downloads
33
License
ISC
Repository
-
Last release
3 years ago

html-docx

this is a simple library to convert html to docx,it is based on the html-doxc-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

Compatibility

This library should work on any modern browser that supports Blobs (either natively or via 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>

  • 这里设置页脚,目前只支持页码

  • 这个元素内部设置需要转换的html内容
  • 页面中需要加入目录的标题需要使用h标签来定义

详细使用例子可以到sample.html中查看

reminder

all classNames or Id of elements in API cannot be changed(上述api中提供的id都不能随便修改)

you can push issues to

License

Copyright (c) 2015 Evidence Prime, Inc. See the LICENSE file for license rights and limitations (MIT).

1.2.0

3 years ago

1.1.20

3 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.16

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago