How to convert .docx to .pdf in C# [closed]

北城余情 提交于 2019-12-20 19:36:50

问题


Now we are using OpenXML to read data from database and generate doc. But the final requirement is to be a pdf. So I want to know how to convert .docx to pdf in C#. Could anyone for help? Or provide some information.


回答1:


You can check solutions in this link: http://www.codeproject.com/Questions/346784/How-to-convert-word-document-to-pdf-in-Csharp

I recommend using this among solutions as first:

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; }
}



回答2:


You could take a look at libraries like iTextSharp



来源:https://stackoverflow.com/questions/19560170/how-to-convert-docx-to-pdf-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!