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
@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框架的预览。
npm install docx-preview
Typescript
Module System
Node Version
NPM Version
TypeScript (52.12%)
HTML (46.68%)
JavaScript (1.21%)
Total Downloads
1,548,831
Last Day
2,165
Last Week
26,877
Last Month
139,892
Last Year
1,070,940
1,356 Stars
188 Commits
177 Forks
22 Watching
3 Branches
8 Contributors
Latest Version
0.3.3
Package Id
docx-preview@0.3.3
Unpacked Size
935.04 kB
Size
200.96 kB
File Count
12
NPM Version
10.5.0
Node Version
21.7.1
Publised On
06 Nov 2024
Cumulative downloads
Total Downloads
Last day
-67.2%
2,165
Compared to previous day
Last week
-24.1%
26,877
Compared to previous week
Last month
7.8%
139,892
Compared to previous month
Last year
184.2%
1,070,940
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 ignoreWidth: boolean = false, //disables rendering width of page
10 ignoreHeight: boolean = false, //disables rendering height of page
11 ignoreFonts: boolean = false, //disables fonts rendering
12 breakPages: boolean = true, //enables page breaking on page breaks
13 ignoreLastRenderedPageBreak: boolean = true, //disables page breaking on lastRenderedPageBreak elements
14 experimental: boolean = false, //enables experimental features (tab stops calculation)
15 trimXmlDeclaration: boolean = true, //if true, xml declaration will be removed from xml documents before parsing
16 useBase64URL: boolean = false, //if true, images, fonts, etc. will be converted to base 64 URL, otherwise URL.createObjectURL is used
17 renderChanges: false, //enables experimental rendering of document changes (inserions/deletions)
18 renderHeaders: true, //enables headers rendering
19 renderFooters: true, //enables footers rendering
20 renderFootnotes: true, //enables footnotes rendering
21 renderEndnotes: true, //enables endnotes rendering
22 renderComments: false, //enables experimental comments rendering
23 debug: boolean = false, //enables additional logging
24 }): Promise<WordDocument>
25
26/// ==== experimental / internal API ===
27// this API could be used to modify document before rendering
28// renderAsync = parseAsync + renderDocument
29
30// parse document and return internal document object
31parseAsync(
32 document: Blob | ArrayBuffer | Uint8Array,
33 options: Options
34): Promise<WordDocument>
35
36// render internal document object into specified container
37renderDocument(
38 wordDocument: WordDocument,
39 bodyContainer: HTMLElement,
40 styleContainer: HTMLElement,
41 options: Options
42): 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.
No vulnerabilities found.
No security vulnerabilities found.