npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

w-html2docx

v1.0.38

Published

A tool for html2docx.

Downloads

549

Readme

w-html2docx

A tool for html2docx.

language npm version license npm download npm download jsdelivr download

Documentation

To view documentation or get support, visit docs.

Core

w-html2docx is based on the win32com in python, and only run in Windows.

Installation

Using npm(ES6 module):

npm i w-html2docx

Example:

Link: [dev source code]

import w from 'wsemi'
import WHtml2docx from './src/WHtml2docx.mjs'
//import WHtml2docx from 'w-html2docx/src/WHtml2docx.mjs'
//import WHtml2docx from 'w-html2docx'

async function test() {

    let fpIn = `./test/ztmp.html`
    let fpOut = `./test/ztmp.docx`
    let opt = {
        imgRatioWidthMax: 0.5,
    }

    let r = await WHtml2docx(fpIn, fpOut, opt)
    console.log(r)
    // => ok

    w.fsDeleteFile(fpOut)

}
test()
    .catch((err) => {
        console.log('catch', err)
    })

外部提供docx模板要點

轉檔時以docx模板為基底產出文件,可透過opt.fpInTemp指定外部模板;未指定時依序使用./src/tmp.docx或./node_modules/w-html2docx/src/tmp.docx(套件內建模板)。

外部提供模板時須注意:

  1. 內容附加於模板文末:轉檔係將html內容(含格式)插入至模板既有內容之後再另存,故模板一般提供空白文件;模板內既有內容會保留於輸出文件開頭。
  2. 頁面設定由模板決定:輸出文件之紙張大小、邊界等頁面設定沿用模板;圖片縮放上限(滿版寬高)亦依模板版心(紙張大小扣除邊界)計算。
  3. 模板settings會帶入輸出文件:模板word/settings.xml內之文件層級設定,轉檔後會保留於輸出docx。
  4. 建議帶入停用影像壓縮旗標:模板word/settings.xml須含<w:doNotAutoCompressPictures/>,否則Word轉檔時會將寬圖(約超過1270px)自動降採樣至220ppi並轉存JPEG,導致圖內文字模糊。套件內建模板已含此旗標;外部模板可於Word開啟模板後,勾選[檔案 > 選項 > 進階 > 影像大小和品質 > 不壓縮檔案中的影像]再存檔,或直接編輯word/settings.xml加入該元素。
  5. 行格線模板之圖名預留:模板設有文件格線(如[版面配置 > 版面設定 > 文件格線 > 只指定行的格線])時,Word會把每段之高度進位為行距之整數倍,整頁高之圖片進位後常擠掉其下之圖名。此時可給opt.imgHeightReserveLines(預留格數),圖片最大高度改為(每頁格數-預留格數)×行距-0.5點,行距取模板文件格線之行距,每頁格數為版心高÷行距之整數部分。例如行距18點、A4上下邊界各72點之模板每頁38格,圖區塊間有1行間隔段、圖名至多2行時至少給3,建議給4多留1格餘裕;14pt之標楷體每行佔2格,須依實際所佔格數加計。模板無文件格線時此設定不生效,圖片最大高度維持版心高×0.937043054427296×opt.imgRatioHeightMax。