Click here to Skip to main content
15,847,427 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to convert ms word file into pdf file using 2012.

For reading Word file, I would recommend using Microsoft Open XML SDK, and for writing PDF — iText, more exactly, its .NET port, iTextSharp.
Please see my past answer: Question Convert word to PDF without offce or openoffice[^].

This is so good if your Word document is in new format, .docx. If this is older .doc, proprietary format, this is also possible, but much more unpleasant. In particular, Libre Office is open source and has the code dealing with old .doc files, and offers it's development API. For further detail, please see my past answers referenced in on of them: How to add microsoft excel 15.0 object library from Add Reference in MS Visual Studio 2010[^].

Share this answer
If you can afford to purchase 3rd party toolkit (like Docentric Toolkit, for example), you will be able to do all sorts of things with your documents. You can create a document from scratch via Docentric APIs. Or you create a template in MS Word and then merge it with data from any source .NET can read.

Generated documents can be native MS Word documents (docx) or fixed documents like pdf or xps. Any Word feature is supported in templates: tables, charts, headers, footers, conditional content, advanced formatting, etc.

Once the document is generated it is in docx format. The code snippet below shows how to save it in pdf format. This snippet is in C#, though.

Document document;
using (FileStream fileStream = File.OpenRead(TestBase.WordDocumentsPath + @"Test1.docx"))
	document = Document.Load(fileStream);		}
	document.Save(TestBase.WordDocumentsPath + @"Test1.pdf");
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900