Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 814
Robin Sun Avatar asked Oct 24 '13 07:10

Robin Sun


People also ask

How do I convert my DOCX To PDF?

The Acrobat Word to PDF online tool lets you convert DOCX, DOC, RTF, and TXT files to PDF using a web browser on any operating system. Just drag and drop a file to convert it and save as PDF.

How do I convert a DOCX file to PDF without Word?

Drag and drop docx file if you have previously downloaded to your computer or mobile. If the docx file you want to open is stored in the cloud, click on Dropbox or Google Drive option, and import docx file from there. The docx file will automatically start to convert to PDF, as soon as you import it.


1 Answers

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; }
}
like image 162
Demir Avatar answered Oct 03 '22 11:10

Demir