question

6666666 avatar image
0 Votes"
6666666 asked ZhiLv-MSFT answered

How to renderer a docx file in the asp.net core web?

I am using asp.net core web

there is a docx file how to render it in the razor pages?

just render it and no need to edit

dotnet-aspnet-core-razor
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ZhiLv-MSFT avatar image
0 Votes"
ZhiLv-MSFT answered

Hi @6666666,

At present we can't directly render the Word Documents on the web page, and as far as I know, there are no client-side libraries that currently exist for rendering them either.

As a workaround, you could upload the word file to OneDrive or Google, then, use Microsoft Office viewer or Google Docs Viewer to render the Word document, then get the shared link. After that you can display the word document using an <iframe> tag.

You could follow the following steps:

  1. Upload the word file to OneDrive.

  2. Choose the word file => click the "View" tab=> and select the "Reading View" option.

    106819-capture2.png

  3. Click the "More" icon, and then choose the "Embed" option,

    106921-capture3.png

  4. Copy the "Embed" code, and paste it in your web page, the code as below:

    106906-capture4.png

  5. The result as below:

    106941-capture5.png

Reference: How do I render a Word document (.doc, .docx) in the browser using JavaScript?


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Best regards,
Dillion


capture2.png (45.7 KiB)
capture3.png (63.3 KiB)
capture4.png (11.0 KiB)
capture5.png (67.5 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.