Rahul Gokani
Rahul Gokani

Reputation: 1708

How to display word document on a aspx page?

I want to display my updated document to the aspx page. I searched a lot for this. But I am not able to find any proper way. I have tried so many things.

  1. I have tried Microsoft Interop dll to convert word document to pdf and then I display pdf file to the page it worked but found Issue that Interop dll cannot be used on production machine. And other thing Interop dlls cannot be copy to project.
  2. I am updating my word document using OpenXml. So I tried OpenXmlPowerTool to convert Document to Html. But It is not converting document properly. Images are not visible some formatting of the text are not proper.

The other problem is that I cannot use third party tool which I have to purchase. I can use only open source product which are freely available.

Can anyone knows how can I do this?
Any suggestions will be appreciated..!

Upvotes: 2

Views: 2018

Answers (2)

Ricardo Appleton
Ricardo Appleton

Reputation: 679

This works for me, but you need to have your document as a binary array. You can, however, work from here:

...
byte[] docFile = null;
...
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "attachment; filename=\"Document.doc\"");
Response.ContentType = "application/x-unknown";
Response.BinaryWrite(docFile);
Response.End();

Note: application/x-unknown is used to force the browser to prompt the user to open or save

Upvotes: 0

Georgy Grigoryev
Georgy Grigoryev

Reputation: 873

You can use some proprietary libraries (like aspose) for converting it into pdf and show that pdf files for user by adobe acrobat kit (codeproject howto).

Upvotes: 1

Related Questions