如何转换的.docx在C#中为.pdf [英] How to convert .docx to .pdf in C#

查看:360
本文介绍了如何转换的.docx在C#中为.pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我们使用的OpenXML读取数据库中的数据并生成文档。但最后的要求就是要PDF文件。所以我想知道怎样的.docx转换为PDF在C#。谁能帮忙? ,或者提供一些信息

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.

推荐答案

您可以检查在这个环节的解决方案:的 http://www.codeproject.com/Questions/346784/How-to-convert -word文档到PDF功能于Csharp的

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

这篇关于如何转换的.docx在C#中为.pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆