Gathering detailed insights and metrics for docx-preview
Gathering detailed insights and metrics for docx-preview
Gathering detailed insights and metrics for docx-preview
Gathering detailed insights and metrics for docx-preview
npm install docx-preview
Typescript
Module System
Node Version
NPM Version
96.8
Supply Chain
96.3
Quality
80.4
Maintenance
100
Vulnerability
98.6
License
TypeScript (52.52%)
HTML (46.3%)
JavaScript (1.18%)
Total Downloads
2,716,308
Last Day
1,759
Last Week
50,582
Last Month
216,354
Last Year
1,782,449
Apache-2.0 License
1,697 Stars
195 Commits
224 Forks
23 Watchers
3 Branches
8 Contributors
Updated on Aug 30, 2025
Latest Version
0.3.6
Package Id
docx-preview@0.3.6
Unpacked Size
957.91 kB
Size
205.11 kB
File Count
12
NPM Version
10.9.2
Node Version
22.14.0
Published on
Jul 22, 2025
Cumulative downloads
Total Downloads
Last Day
21%
1,759
Compared to previous day
Last Week
0.7%
50,582
Compared to previous week
Last Month
2.7%
216,354
Compared to previous month
Last Year
151.7%
1,782,449
Compared to previous year
Docx rendering library
Demo - https://volodymyrbaydalka.github.io/docxjs/
Goal of this project is to render/convert DOCX document into HTML document with keeping HTML semantic as much as possible. That means library is limited by HTML capabilities (for example Google Docs renders *.docx document on canvas as an image).
npm install docx-preview
1<!--lib uses jszip--> 2<script src="https://unpkg.com/jszip/dist/jszip.min.js"></script> 3<script src="docx-preview.min.js"></script> 4<script> 5 var docData = <document Blob>; 6 7 docx.renderAsync(docData, document.getElementById("container")) 8 .then(x => console.log("docx: finished")); 9</script> 10<body> 11 ... 12 <div id="container"></div> 13 ... 14</body>
1// renders document into specified element
2renderAsync(
3 document: Blob | ArrayBuffer | Uint8Array, // could be any type that supported by JSZip.loadAsync
4 bodyContainer: HTMLElement, //element to render document content,
5 styleContainer: HTMLElement, //element to render document styles, numbeings, fonts. If null, bodyContainer will be used.
6 options: {
7 className: string = "docx", //class name/prefix for default and document style classes
8 inWrapper: boolean = true, //enables rendering of wrapper around document content
9 hideWrapperOnPrint: boolean = false, //disable wrapper styles on print
10 ignoreWidth: boolean = false, //disables rendering width of page
11 ignoreHeight: boolean = false, //disables rendering height of page
12 ignoreFonts: boolean = false, //disables fonts rendering
13 breakPages: boolean = true, //enables page breaking on page breaks
14 ignoreLastRenderedPageBreak: boolean = true, //disables page breaking on lastRenderedPageBreak elements
15 experimental: boolean = false, //enables experimental features (tab stops calculation)
16 trimXmlDeclaration: boolean = true, //if true, xml declaration will be removed from xml documents before parsing
17 useBase64URL: boolean = false, //if true, images, fonts, etc. will be converted to base 64 URL, otherwise URL.createObjectURL is used
18 renderChanges: false, //enables experimental rendering of document changes (inserions/deletions)
19 renderHeaders: true, //enables headers rendering
20 renderFooters: true, //enables footers rendering
21 renderFootnotes: true, //enables footnotes rendering
22 renderEndnotes: true, //enables endnotes rendering
23 renderComments: false, //enables experimental comments rendering
24 renderAltChunks: true, //enables altChunks (html parts) rendering
25 debug: boolean = false, //enables additional logging
26 }): Promise<WordDocument>
27
28/// ==== experimental / internal API ===
29// this API could be used to modify document before rendering
30// renderAsync = parseAsync + renderDocument
31
32// parse document and return internal document object
33parseAsync(
34 document: Blob | ArrayBuffer | Uint8Array,
35 options: Options
36): Promise<WordDocument>
37
38// render internal document object into specified container
39renderDocument(
40 wordDocument: WordDocument,
41 bodyContainer: HTMLElement,
42 styleContainer: HTMLElement,
43 options: Options
44): Promise<void>
Thumbnails is added only for example and it's not part of library. Library renders DOCX into HTML, so it can't be efficiently used for thumbnails.
Table of contents is built using the TOC fields and there is no efficient way to get table of contents at this point, since fields is not supported yet (http://officeopenxml.com/WPtableOfContents.php)
Currently library does break pages:
<w:br w:type="page"/>
is inserted - when user insert page break<w:lastRenderedPageBreak/>
is inserted - could be inserted by editor application like MS word (ignoreLastRenderedPageBreak
should be set to false)Realtime page breaking is not implemented because it's requires re-calculation of sizes on each insertion and that could affect performance a lot.
If page breaking is crutual for you, I would recommend:
<w:lastRenderedPageBreak/>
break pointsNOTE: by default ignoreLastRenderedPageBreak
is set to true
. You may need to set it to false
, to make library break by <w:lastRenderedPageBreak/>
break points
So far I can't come up with final approach of parsing documents and final structure of API. Only renderAsync function is stable and definition shouldn't be changed in future. Inner implementation of parsing and rendering may be changed at any point of time.
Please do not include contents of ./dist
folder in your PR's. Otherwise I most likely will reject it due to stability and security concerns.
No vulnerabilities found.
@vue-office/docx
支持多种文件(**docx、excel、pdf、pptx**)预览的vue组件库,支持vue2/3。也支持非Vue框架的预览。
@js-preview/docx
支持多种文件(**docx、excel、pdf、pptx**)预览的vue组件库,支持vue2/3。也支持非Vue框架的预览。
@vue-office/excel
支持多种文件(**docx、excel、pdf、pptx**)预览的vue组件库,支持vue2/3。也支持非Vue框架的预览。
@vue-office/pdf
支持多种文件(**docx、excel、pdf、pptx**)预览的vue组件库,支持vue2/3。也支持非Vue框架的预览。