Cyberiafreak

"Fortunate are those who take the first steps.” ― Paulo Coelho

How to convert word document to PDF using MS PIA Interop libraries.

For Word interop ref: c:\Program Files (x86)\Microsoft Visual Studio 12.0\Visual Studio Tools for Office\PIA\Office14\Microsoft.Office.Interop.Word.dll

using System;

using System.Reflection;

using Word = Microsoft.Office.Interop.Word;

namespace ConsoleApplication5

{

classProgram

{

staticvoid Main(string[] args)

{

Application app = new Word.Application();

Missing ms = Missing.Value;

Document doc = app.Documents.Open(“D:\\Inputlog.doc”, ms, ms, ms, ms, ms, ms, ms, ms, ms, ms, ms, ms, ms, ms, ms);

doc.ExportAsFixedFormat(“D:\\dave_sample.pdf”, Word.WdExportFormat.wdExportFormatPDF, false, Word.WdExportOptimizeFor.wdExportOptimizeForPrint, Word.WdExportRange.wdExportAllDocument, 1, 1, Word.WdExportItem.wdExportDocumentContent, false, true, Word.WdExportCreateBookmarks.wdExportCreateNoBookmarks, false, true, false);

}

}

Advertisements

May 15, 2014 - Posted by | Uncategorized |

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: