Convert of word file(.docx & doc) to .pdf using c# is not working

前端 未结 3 1736
心在旅途
心在旅途 2021-01-03 08:48

I am using visualstudio 2010 and I am trying to convert word.docx file to .pdf file and is working fine in local but on run time on server it is showing error as

<         


        
相关标签:
3条回答
  • 2021-01-03 09:08

    You will need to install the "office.dll" library in the Global Assembly Cache on the server too to make this work. Check out the C:\Windows\assembly folder and you will find office.dll there.

    EDIT: It seems that this will not be as simple as it looks. Some developers mention here that Office would have to be installed on the server or you will need to install even more libraries manually.

    0 讨论(0)
  • 2021-01-03 09:11

    I had long been looking for a solution to these issues and in the end I had to use a third party. I suggest you use a third party like Aspose Aspose.Total for .NET

    Aspose.Words for .NET is an advanced class library for .NET that enables you to perform a wide range of document processing tasks directly within your .NET applications.

    With Aspose.Words you can generate, modify, convert, render and print documents without using Microsoft Word.

    Aspose.Words for .NET supports DOC, OOXML, RTF, HTML, OpenDocument, PDF, XPS, EPUB and many other formats.

    This component work perfectly for me and very simple to use. this is an example of convert word to pdf code :

    Document doc = new Document(getMyDir() + "Document.doc");
    doc.save(getMyDir() + "Document.Doc2PdfSave Out.pdf");
    
    0 讨论(0)
  • 2021-01-03 09:12

    It is not recommended to use the Office interop in a server environment due to the memory leaks and perfomance issues. You will have to look for a managed solution to convert PDF to word in a server, than installing the office package and the interop assemblies there. There are a few managed components which can get the work done, but they are not free.

    http://www.aspose.com/.net/pdf-component.aspx http://www.websupergoo.com/wordglue-1.htm

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