Docx rendering library
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
<script src="https://unpkg.com/jszip/dist/jszip.min.js"></script>
<script src="docx-preview.min.js"></script>
<script>
var docData = <document Blob>;
docx.renderAsync(docData, document.getElementById("container"))
.then(x => console.log("docx: finished"));
</script>
<body>
...
...
</body>…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 crucial 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 open issues yet, or sync has not completed.