Is Microsoft.Office.Interop safe to use for (file-converting) for a website?

前端 未结 1 568
广开言路
广开言路 2021-01-21 17:23

I am coding a website on witch users have to add reports (Word document\'s) and to make possible to view them I convert *.doc to *.pdf, and then displaying them throught pdf.js.

1条回答
  •  生来不讨喜
    2021-01-21 17:51

    The answer, from Microsoft, is no:

    Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

    From Considerations for Server-Side Automation of Office

    From experience, here are the issues we encountered:

    • When the process exists unexpectedly, lots of Word instances are left around, and are never cleaned up
    • The Word installation became corrupt after a shutdown occurred half-way through a processing session
    • It doesn't scale remarkably well - Word is a large desktop application that is excellent at what it does; however, it's not really meant for the process you are using it for, and, as such, opening lots of instances of it will consume resources that your application could use.

    There are other ways to do this, however, as covered in this StackOverflow question and answers

    You may consider pre-converting the word documents - for example, is it possible, when the document is uploaded, to also create the PDF then? That way, your server is simply serving up a PDF document and has to do very little work in servicing the request.

    0 讨论(0)
提交回复
热议问题