I am trying to convert docx file in pdf and I have been suceeded to convert pdf on local.
我正在尝试将docx文件转换成pdf格式,并在本地将其转换成pdf格式。
Steps which i have followed in visual studio 2010
is to
我在visual studio 2010中遵循的步骤是。
click on Add reference --> Click to COM -->select "Microsoft Word 12.0 Object Library" and cliked ok
My web config get modified and added assembly
我的web配置被修改并添加了程序集。
<add assembly="Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/>
My .cs code for converting doc to pdf is
我的。cs代码将doc转换为pdf。
using Microsoft.Office.Interop.Word;//Name Space
protected void Page_Load(object sender, EventArgs e)//Coading on page load
{
Microsoft.Office.Interop.Word.Application appWord = new Microsoft.Office.Interop.Word.Application();
wordDocument = appWord.Documents.Open(Server.MapPath("~/convert/goodquest.docx"));
wordDocument.ExportAsFixedFormat(Server.MapPath("~/convert/goodquest.pdf"), WdExportFormat.wdExportFormatPDF);
}
public Microsoft.Office.Interop.Word.Document wordDocument { get; set; }
All works fine in local
but when i upload
all this changes on web
.
所有的工作在本地都很好,但是当我在网上上传所有这些改变的时候。
Error such as
错误,如
Could not load file or assembly 'Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.
is coming. How should i resolve this problem
即将来临。我该如何解决这个问题?
I have also tried downloading "Microsoft Office 2010: Primary Interop Assemblies Redistributable" from link Here but it converted my "Version=12.0.0.0" to "Version=14.0.0.0" when i follow steps which i have said you firstly as " click on Add reference --> Click to COM........"
我也尝试过下载“微软Office 2010:初级互操作程序集再分配”,但它将我的“Version=12.0.0.0”转换为“Version=14.0.0.0”,当我按照我之前说过的步骤,“点击添加参考——>点击进入COM……”
4 个解决方案
#1
3
Copy paste the Microsoft.Office.Interop.Word.dll
into bin folder in server.
复制粘贴Microsoft.Office.Interop.Word。dll在服务器中的bin文件夹。
It's may be added in this path
它可以在这条路径中添加。
%ProgramFiles%\Microsoft Visual Studio 12.0\Visual Studio Tools for Office\PIA\
but i don't know is it correct : more details please see this MSDN Link
%的程序文件%\ microsoftvisual Studio 12.0\Visual Studio工具为Office\PIA\但我不知道是正确的:更多的细节请看这个MSDN链接。
else, You can download this dll : https://*.com/a/6309218/2218635
另外,您可以下载这个dll: https://*.com/a/6309218/2218635。
#2
0
Have you copied DLL (Microsoft.Office.Interop.Word) to the executable path?
您是否将DLL (Microsoft.Office.Interop.Word)复制到可执行路径中?
you have to copy this DLL to local path else the Microsoft office must be installed on this server.
您必须将此DLL复制到本地路径,而Microsoft office必须安装在此服务器上。
Looking into error it seems that application is not able to find the file in specified path.
在查找错误时,应用程序似乎无法找到指定路径中的文件。
By default application will find the DLL first into GAC else into local path. There can be other reason like the version is different, in such case also you will get similar error.
默认情况下,应用程序将会发现DLL首先进入到本地路径的GAC else中。可能还有其他原因,比如版本是不同的,在这种情况下,你也会得到类似的错误。
#3
0
You have missed the dell version.
你错过了戴尔的版本。
Please download correct version of the dll.
请下载正确版本的dll。
#4
0
Correct procedure to use Word in C# Projects is:
在c#项目中使用Word的正确程序是:
- Add reference to Word Interop Library(Assembly)
- 添加对Word Interop库(汇编)的引用
- Add Excel in
using
section - 在使用部分添加Excel。
- Now use it in your coding.
- 现在在你的代码中使用它。
The first step will work if you have Office(Word) Installed in your PC. If not then install. Then add reference to Microsoft.Office.Interop.Word
of the version you need.
如果你在你的电脑上安装了Office(Word),那么第一步就可以实现了。如果没有安装。然后添加对Microsoft.Office.Interop的引用。你需要的版本。
a. If list doesn't shows the desire version then you may have another vision of Office with Word installed. By The Way, you can use any.
如果列表中没有显示愿望版本,那么您可能会有另一个关于Word安装的办公室愿景。顺便说一下,你可以用。
b. If you don't find anything like Microsoft.Office.Interop
THEN may be office not installed OR you have Office 2013 or later. For higher version you can add assembly by going into COM tab of add-reference windows and add Microsoft Word {version-no} Object Library
. This will add the same.
如果你找不到像微软办公室这样的东西。Interop可能是办公室没有安装,也可能是2013年或以后。对于更高版本,您可以通过进入add-reference窗口的COM选项卡来添加程序集,并添加Microsoft Word {version-no}对象库。这将添加相同的内容。
c. If you already have Microsoft.Office.Interop...
in References with yellow-triangle-mark THEN remove it first.
如果你已经有Microsoft.Office.Interop……在带有黄-三角形标记的引用中,首先删除它。
After that second step will totally work: using Word=Microsoft.Office.Interop.Word;
在那之后,第二步将完全发挥作用:使用Word=Microsoft.Office.Interop.Word;
And finally as a third step you can create Word object by Word.Application wApp = new Word.Application();
.
最后,作为第三步,你可以用Word来创建Word对象。应用程序wApp = new Word.Application();
#1
3
Copy paste the Microsoft.Office.Interop.Word.dll
into bin folder in server.
复制粘贴Microsoft.Office.Interop.Word。dll在服务器中的bin文件夹。
It's may be added in this path
它可以在这条路径中添加。
%ProgramFiles%\Microsoft Visual Studio 12.0\Visual Studio Tools for Office\PIA\
but i don't know is it correct : more details please see this MSDN Link
%的程序文件%\ microsoftvisual Studio 12.0\Visual Studio工具为Office\PIA\但我不知道是正确的:更多的细节请看这个MSDN链接。
else, You can download this dll : https://*.com/a/6309218/2218635
另外,您可以下载这个dll: https://*.com/a/6309218/2218635。
#2
0
Have you copied DLL (Microsoft.Office.Interop.Word) to the executable path?
您是否将DLL (Microsoft.Office.Interop.Word)复制到可执行路径中?
you have to copy this DLL to local path else the Microsoft office must be installed on this server.
您必须将此DLL复制到本地路径,而Microsoft office必须安装在此服务器上。
Looking into error it seems that application is not able to find the file in specified path.
在查找错误时,应用程序似乎无法找到指定路径中的文件。
By default application will find the DLL first into GAC else into local path. There can be other reason like the version is different, in such case also you will get similar error.
默认情况下,应用程序将会发现DLL首先进入到本地路径的GAC else中。可能还有其他原因,比如版本是不同的,在这种情况下,你也会得到类似的错误。
#3
0
You have missed the dell version.
你错过了戴尔的版本。
Please download correct version of the dll.
请下载正确版本的dll。
#4
0
Correct procedure to use Word in C# Projects is:
在c#项目中使用Word的正确程序是:
- Add reference to Word Interop Library(Assembly)
- 添加对Word Interop库(汇编)的引用
- Add Excel in
using
section - 在使用部分添加Excel。
- Now use it in your coding.
- 现在在你的代码中使用它。
The first step will work if you have Office(Word) Installed in your PC. If not then install. Then add reference to Microsoft.Office.Interop.Word
of the version you need.
如果你在你的电脑上安装了Office(Word),那么第一步就可以实现了。如果没有安装。然后添加对Microsoft.Office.Interop的引用。你需要的版本。
a. If list doesn't shows the desire version then you may have another vision of Office with Word installed. By The Way, you can use any.
如果列表中没有显示愿望版本,那么您可能会有另一个关于Word安装的办公室愿景。顺便说一下,你可以用。
b. If you don't find anything like Microsoft.Office.Interop
THEN may be office not installed OR you have Office 2013 or later. For higher version you can add assembly by going into COM tab of add-reference windows and add Microsoft Word {version-no} Object Library
. This will add the same.
如果你找不到像微软办公室这样的东西。Interop可能是办公室没有安装,也可能是2013年或以后。对于更高版本,您可以通过进入add-reference窗口的COM选项卡来添加程序集,并添加Microsoft Word {version-no}对象库。这将添加相同的内容。
c. If you already have Microsoft.Office.Interop...
in References with yellow-triangle-mark THEN remove it first.
如果你已经有Microsoft.Office.Interop……在带有黄-三角形标记的引用中,首先删除它。
After that second step will totally work: using Word=Microsoft.Office.Interop.Word;
在那之后,第二步将完全发挥作用:使用Word=Microsoft.Office.Interop.Word;
And finally as a third step you can create Word object by Word.Application wApp = new Word.Application();
.
最后,作为第三步,你可以用Word来创建Word对象。应用程序wApp = new Word.Application();