Asked  7 Months ago    Answers:  5   Viewed   103 times

I have successfully done code to display a PDF file in the browser instead of the "Open/Save" dialog. Now, I'm stuck trying to display a Word document in the browser. I want to display a Word document in Firefox, IE7+, Chrome etc.

Can any one help? I am always getting the "Open/Save" dialog while displaying the Word doc in browser. I want to implement this functionality using JavaScript.



No browsers currently have the code necessary to render Word Documents, and as far as I know, there are no client-side libraries that currently exist for rendering them either.

However, if you only need to display the Word Document, but don't need to edit it, you can use Google Documents' Viewer via an <iframe> to display a remotely hosted .doc/.docx.

<iframe src=""></iframe>

Solution adapted from "How to display a word document using fancybox".



However, if you'd rather have native support, in most, if not all browsers, I'd recommend resaving the .doc/.docx as a PDF file Those can also be independently rendered using PDF.js by Mozilla.


Huge thanks to fatbotdesigns for posting the Microsoft Office 365 viewer in the comments.

<iframe src='' width='1366px' height='623px' frameborder='0'>This is an embedded <a target='_blank' href=''>Microsoft Office</a> document, powered by <a target='_blank' href=''>Office Online</a>.</iframe>

One more important caveat to keep in mind, as pointed out by lightswitch05, is that this will upload your document to a third-party server. If this is unacceptable, then this method of display isn't the proper course of action.

Live Examples:

Google Docs Viewer

Microsoft Office Viewer

Tuesday, June 1, 2021
answered 7 Months ago

Perhaps it's because you're opening some .class files outside the jar file?

That way it may not display the warning. I tried doing it that way but it still showed me the certificate warning and for a simple case it actually prevented me from accessing a class from the JAR with the separated class.

Maybe your specific setup or file organization causes that behavior. If you can layout that in more detail we could help better (or rather, try putting all those .class files in yet another signed Jar and add it to the archive"..., anotherJar.jar").

Wednesday, June 16, 2021
answered 6 Months ago

You can create OpenXML documents using the Open XML SDK 2.0 for Microsoft Office. Note that this only applies to .docx, not .doc binary files from earlier versions of Word.

Documentation can be found here.

Friday, July 30, 2021
answered 4 Months ago

I believe that many people have tried to do something close to what you are attempting and failed. There is a lot of chatter about not being able to run any office interop based solutions in a server-like mode (unattended etc).

See here and here

I know this is probably not the answer you were looking for but it is nevertheless how it is!

Wednesday, September 15, 2021
answered 3 Months ago

Try this variant:

oTable.Cell(r, c).Range.Borders[WdBorderType.wdBorderLeft].LineStyle = WdLineStyle.wdLineStyleSingle;
oTable.Cell(r, c).Range.Borders[WdBorderType.wdBorderRight].LineStyle = WdLineStyle.wdLineStyleSingle;
oTable.Cell(r, c).Range.Borders[WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleSingle;
oTable.Cell(r, c).Range.Borders[WdBorderType.wdBorderBottom].LineStyle = WdLineStyle.wdLineStyleSingle;

Put in cycle.

Also you can set line width and color:

oTable.Cell(r, c).Range.Borders[WdBorderType.wdBorderBottom].LineWidth = WdLineWidth.wdLineWidth050pt;
oTable.Cell(r, c).Range.Borders[WdBorderType.wdBorderBottom].Color = WdColor.wdColorRed;
Friday, October 22, 2021
answered 1 Month ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :