Giter Club home page Giter Club logo

html-docx's Introduction

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 install html-docx --save

import HtmlToDocx from 'html-docx'
HtmlDocx({
    exportElement: '#html-docx', // 需要转换为word的html标签
    exportFileName: 'list.docx', // 转换之后word文档的文件名称
    StringStyle: '', // css样式以字符串的形式插入进去
    margins:{top: 1440,right: 1440,bottom: 1440,left: 1440,header: 720,footer: 720,gutter: 0} // 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 cavans can be generate by common charts library or protogenetic

API

<div id="html-docx-config">
  • the container is used to set the WORD that you will convert
<div id="page-header" textAlign='right'>我的新世界</div>
  • the element is used to control the header of word
  • the property is used to set the position of the header
  • the innerText of the element is content of the header
<div id="first-page" titlePg='false'><div style='text-align: center;'>dfsdfsdf</div></div>
  • the element is used to control the header of first page,if the first titlePage is needless for you ,you can skip the element
  • the property(titlePg) is used to defined the first page whether or not the same
  • you can edite any html element in the element

<div id="page-content"></div>

  • the element is used to control the content of word,if you neednot the content,you can skip the element

<div class="change-line"></div>

  • if you want to start with a new page, you can used the element
  • you can you use id any time only if you want

<div id="page-footer"></div>

  • the element is used to control the header of word
  • it can only be used to disply page number

reminder

all classNames or Id of elements in API cannot be changed you had better use protogenetic element in html so that the word can convert accurately

License

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.