TurboDocx / html-to-docx

HTML to DOCX converter
https://TurboDocx.com
MIT License
48 stars 5 forks source link
document documentation-generator html-to-docx javascript nodejs npm-module npm-package

TurboDocx

html-to-docx

NPM Version Discord npm X Embed TurboDocx in Your App in Minutes

@turbodocx/html-to-docx is a powerful JavaScript library designed to convert HTML documents to DOCX format, compatible with Microsoft Word 2007+, LibreOffice Writer, Google Docs, WPS Writer, and other word processors. Inspired by @PrivateOmega, this is supported by TurboDocx to ensure ongoing development and improvements.

Disclaimer

While @turbodocx/html-to-docx is robust and used in production environments, it is continually evolving. Please ensure it meets your specific needs through thorough testing. Note that it currently does not work directly in the browser.

Installation

Use the npm to install the project.

npm install @turbodocx/html-to-docx

Usage

await HTMLtoDOCX(htmlString, headerHTMLString, documentOptions, footerHTMLString)

full fledged examples can be found under example/

Parameters

Returns

<Promise<Buffer|Blob>>

Notes

Currently page break can be implemented by having div with classname "page-break" or style "page-break-after" despite the values of the "page-break-after", and contents inside the div element will be ignored. <div class="page-break" style="page-break-after: always;"></div>

CSS list-style-type for <ol> element are now supported. Just do something like this in the HTML:

  <ol style="list-style-type:lower-alpha;">
    <li>List item</li>
    ...
  </ol>

List of supported list-style-types:

Also you could add attribute data-start="n" to start the numbering from the n-th.

<ol data-start="2"> will start the numbering from ( B. b. II. ii. 2. )

Font family doesnt work consistently for all word processor softwares

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to branch new branches off of develop for contribution.

Support

Proudly Sponsored by TurboDocx "Proudly Sponsored by TurboDocx"

License

MIT

Contributors

Made with contrib.rocks.