我希望您能够将docx文件转换为pdf,我已经成功地在我的本地电脑上进行了转换。
我在Visual Studio 2010
中遵循的步骤是:
click on Add reference --> Click to COM -->select "Microsoft Word 12.0 Object Library" and cliked ok
我的Web配置文件被修改并添加了程序集
<add assembly="Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/>
我转换doc到pdf的.cs代码如下:
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; }
所有代码在本地运行良好,但是上传到 Web 后会发生变化。
出现的错误如下:
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.
出现了一些问题,该怎么解决呢?
我还尝试从这里下载了“Microsoft Office 2010:主要Interop程序集可再分发”,但是当我按照之前告诉您的步骤“点击添加引用-->单击COM........”时,它将我的“版本=12.0.0.0”转换为“版本=14.0.0.0”。