html-to-word-convertor
v3.0.9
Published
Html to word document
Downloads
7
Readme
HTML to Word Document Converter
Introduction
The HTML to Word Document Converter is a tool designed to convert HTML content into Microsoft Word (.docx) format. This documentation provides instructions on how to use the converter in various environments such as JavaScript, Node.js, or React.js.
Features
- Converts HTML content to Microsoft Word (.docx) format.
- Supports basic HTML elements such as text, paragraphs, headings, lists, tables, and images.
- Easy to integrate into different environments.
Installation
JavaScript
<script type="module">
import {convertHtmlPageToWordJavascript} from 'https://cdn.jsdelivr.net/npm/[email protected]/javascript_index.min.js'
convertHtmlPageToWordJavascript(document.documentElement.innerHTML, 'test.docx')
</script>
Node.js
npm install html-to-word-convertor
npm add fs
import { convertHtmlPageToWordNode } from 'html-to-word-convertor/convertHtmlPageToWordNode'
const asyncProcessForHtmlParseToDocx = async (htmlContent) => {
await convertHtmlPageToWordNode(htmlContent, "demo.docx")
}
const htmlContent = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1 style="color:red;">Hello World Node.js</h1>
</body>
</html>`
asyncProcessForHtmlParseToDocx(htmlContent)
React js
npm install html-to-word-convertor
import { convertHtmlPageToWordJavascript } from 'html-to-word-convertor/convertHtmlPageToWordJavascript';
const asyncProcessForHtmlParseToDocx = async () => {
await convertHtmlPageToWordJavascript(document.documentElement.innerHTML, 'demo.docx');
}
API Reference
convertHtmlPageToWord(htmlContent: string, env: string): Promise
- htmlContent: HTML content string to be converted.
- fileName: File name that you want to save docx ex: test.docx
- Returns: Promise resolving to void.
Examples
- Basic HTML to Word conversion.
- Conversion with custom styling.
- Conversion with images.
Contributing
- Contributions to this project are welcome. Feel free to fork the repository, make your changes, and submit a pull request.
License
This project is licensed under the MIT License.
Support
For any issues or queries, please contact [[email protected]].