现在我们正在使用OpenXML从数据库读取数据并生成doc文件。但是最终要求生成pdf文件。因此我想知道如何在C#中将.docx转换为pdf。能否提供帮助或提供一些信息。
现在我们正在使用OpenXML从数据库读取数据并生成doc文件。但是最终要求生成pdf文件。因此我想知道如何在C#中将.docx转换为pdf。能否提供帮助或提供一些信息。
您可以在此链接中查看解决方案:http://www.codeproject.com/Questions/346784/How-to-convert-word-document-to-pdf-in-Csharp
我建议首先使用以下解决方案:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Office.Interop.Word;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Microsoft.Office.Interop.Word.Application appWord = new Microsoft.Office.Interop.Word.Application();
wordDocument = appWord.Documents.Open(@"D:\desktop\xxxxxx.docx");
wordDocument.ExportAsFixedFormat(@"D:\desktop\DocTo.pdf", WdExportFormat.wdExportFormatPDF);
}
public Microsoft.Office.Interop.Word.Document wordDocument { get; set; }
}