New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

word-to-html

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

word-to-html

convert docx files to html

  • 2.2.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
55
Maintainers
1
Weekly downloads
 
Created
Source

word-to-html

A tiny tool to convert Microsoft Word document to HTML in Nodejs and in chrome, you can use the tool convert tables with merged cells and nested tables to html file in Nodejs or chrome, the online tool wordhtml can not do this. Beyond that, you can convert words with different font-family or font-size in a line to html string in chrome.

table example

example.html(mobile)

attention

If a line of words have different font-family or font-size in your .docx, it can not convert your .docx to html expectly in nodejs, but this can be fixed in the browsers such as chrome. because the npm package jsdom can not realize the DOMParser's function perfectly. So if you want to convert the font-family and font-size exactly, you can see how to use word2html.js in browsers!

Install

npm i word-to-html --save-dev

or

yarn add word-to-html

api in nodejs: word2html(absPath [,options,env])

absPath: string | Array<string>

absPath is your file's absolute path

options: {tdTextAlign:string,tdVerticalAlign:string}

tdTextAlign controls the <td> tag's text-align

tdVerticalAlign controls the <td> tag's vertical-align

env: 'node' | 'browser'

default value is 'node',if you want to convert the font-family/font -size/color, env must be 'browser', then you get a .html file, after you open the .html file in chrome, you will get a string in console panel, the result is what you want.

Usage in nodejs

var path = require('path');
var word2html = require('word-to-html');
//Word document's absolute path
var absPath = path.join(__dirname,'test.docx');
word2html(absPath,{tdVerticalAlign:'top'})

the html generated in your WorkSpace.

Usage in browsers

step 1: execute the code below in your node
var path = require('path');
var word2html = require('word-to-html');
//Word document's absolute path
var absPath = path.join(__dirname,'test.docx');
word2html(absPath,{tdVerticalAlign:'top'},'browser')
step 2: get the html string in your browser

open the html file generated just now, and copy the result string of the console panel into your html tempalte, you will see the content of your .docx file will be in your html template.

Keywords

FAQs

Package last updated on 26 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc