none
How to display a Word document (*.docx) in a WinForm-Application? RRS feed

  • Question

  • Is there a better approach to display a Word document in my application than converting it to html and display it in an htmlviewer control using one of these two methods:
    http://codinglight.blogspot.ch/2008/10/simple-docbrowser-control.html
    http://msdn.microsoft.com/en-us/library/ff628051(v=office.14).aspx ?

    I do not like these two approaches.. the first requires MS Word to be installed on the user's machine and the second does not display the formatting correctly.

    I only want to display the documet, like an image. The user does not need to be able to interact with the document (such as marking text, etc.). A function which simply renders the document into a Bitmap would be a convenient solution for me, but I guess that does not exist.. I looked into the Open Xml SDK but it contains a great number of classes and its not really documented well, so if there was a class which provided such a method, I overlooked it...

    It would also be ok for me, if the document was converted to a PDF, if that could be done easier.

    So I would be really grateful if someone pointed me into the right direction :)

    Note: Im looking for something (a library/sdk/etc.) which does the task for me. I do not have the time (and propably not the knowledge) to write my own WordRenderer implementation atop the Open Xml SDK.

    See: http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/bb5319a3-ddc7-42b5-a9b4-034a26b89314

    Thursday, March 21, 2013 12:26 PM

Answers

  • Hi Argus,

    you can converted the document to PDF format, In order to covert document to a PDF, you can use the following codes(Document.ExportAsFixedFormat method):

     Globals.ThisAddIn.Application.ActiveDocument.ExportAsFixedFormat(
                                    saveFileDialog.FileName,
                                    Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF);

     Thanks.
    • Marked as answer by ArgusMagnus Tuesday, March 26, 2013 8:56 AM
    Friday, March 22, 2013 2:31 AM

All replies