7

I am searching for a JavaScript library that is similar to pdf.js but allows the viewing of Word Documents (.doc and .docx)

Are there any?

UPDATE:

There is an interesting library called DOCX.js

But I'm searching for something more advanced.

Lee Taylor
  • 7,761
  • 16
  • 33
  • 49
obenjiro
  • 3,665
  • 7
  • 44
  • 82
  • This is an off-topic question. Please see #4 on https://stackoverflow.com/help/on-topic – Robert Talada Jan 22 '19 at 22:00
  • @RobertTalada I disagree with this definition. I understand why you may have come to this conclusion. I have tried to find library, unfortunately at the time I didn't know about Word Documents containing ActiveX, OLE objects. So from my point of view this was a legitimate question – obenjiro Jan 24 '19 at 14:16
  • @Ai_boy, can you please provide any tutorial to create preview using docx.js? – chithra Feb 26 '19 at 10:03

5 Answers5

3

I doubt it. Behind pdf.js stands Mozilla, so it isn't a weekend project.

There are options to let LibreOffice run in the browser, but I have no first-hand experience with it. Apparently, some cloud projects like NextCloud use it, though.

Then you have Google Docs to import the Word file and let it be displayed there, but there is no way to embed that easily or even host the code yourself. (Also, as I understand it, there are transformations to the Word file on the server involved.)

And after all, if you compare the PDF spec with the OpenXML (aka .docx) spec, it becomes quite clear, that a fully compliant viewer will be a complex beast, to say the least.

Boldewyn
  • 81,211
  • 44
  • 156
  • 212
  • pdf (500 pages) - contains specs only for one document format, openXML (4000 pages) contains specs for 4 at least - Word, Excel, PowerPoint, Outlook so i personally think that OpenXML specs for Word Documents is not "so much" harder. – obenjiro Jan 03 '13 at 17:57
  • 2
    Except that you can embed many of those pieces within a word document, so for a proper viewer you do need to take into account almost all of those specs. I wrote a spreadsheet exporter and was thinking of allowing imports as well.. after looking over what I might have to deal with, I said f* it and moved on ;) – Stephen Jan 03 '13 at 18:01
2

I just found out ViewerJS, but it only supports OpenDocument formats. It's not what you were looking for, but may be worth a shot, specially if you can find a way to convert odt to doc (this question might help).

Community
  • 1
  • 1
kepler
  • 1,712
  • 17
  • 18
1

At a glance, it looks like Flexpaper can be used to this effect, but it's effectively using a server-side version of open office to convert the document into images that can be viewed on the web. This'll work in a pinch, but certainly lacks the quality of pdf.js.

Bubbles
  • 3,795
  • 1
  • 24
  • 25
0

You can use ViewerJS and JOD Converter (http://www.artofsolving.com/opensource/jodconverter.html) together to achieve requirement. First you can convert office documents to open office or pdf format using above converter. Then you can show those documents with the help of either pdf.js or ViewerJS

0

Native Documents (in which I have an interest) makes an embeddable viewer/editor for Word documents. There's an online demo where you can try your own document.

JasonPlutext
  • 15,352
  • 4
  • 44
  • 84