Support us on YouTube by Subscribing our YouTube Channel. Click here to Subscribe our YouTube Channel

Thursday 27 August 2015

Convert Word Document to PDF using Spire.Doc

Recently, I am working on a project in which I have to give functionality to convert Word Document to PDF. I searched a lot and found Spire.Doc (a product of e-iceblue company which provides .NET, Silverlight and WPF development components).

Spire.Doc for .NET is a professional Word. NET library specially designed for developers to create, read, write, convert and print Word document files from any .NET( C#, VB.NET, ASP.NET) platform with fast and high-quality performance.

You can also download Free edition of Spire.Doc. Free Spire.Doc for .NET is a Community Edition of the Spire.Doc for .NET, which is a totally free word component for commercial and personal use with some limitation.

Free Spire.Doc for .Net

I have downloaded Spire.Office which includes Spire.Doc as well as other components (Spire XLS, Spire.Presentation, Spire.PDF, Spire.DataExport, Spire.PDFViewer, Spire.DocViewer and Spire.BarCode). You can also Download Spire.Office or Spire.Doc from these links.

After Downloading, Install the Spire.Office or Spire.Doc (whatever you have downloaded).

Let's Begin:
Create New Windows Form Application. I have selected .Net framework 4.
Right Click on References in Solution Explorer and Click on Add Reference.
In Reference Manager, Click on Browse tab
Now go to  C:\Program Files (x86)\e-iceblue\Spire.Office\Bin\NET4.0 and Add Spire.Doc.dll in your project.

After Adding, you will see Spire.Doc dll reference added to your project.
Now, Drop a button(named as btnConvert) control on the form and double click on it to create its Click event.
Add Spire.Doc and Spire.Doc.Documents namespace in .cs Code.
Add the following lines of Code in button Click event:
private void btnConvert_Click(object sender, EventArgs e)
{
    //Load Document
    Document doc = new Document();
    //Pass path of Word Document in LoadFromFile method
    doc.LoadFromFile(@"C:\Users\Anoop Kumar Sharma\Desktop\Coding.Docx");
    //Pass Document Name and FileFormat of Document as Parameter in SaveToFile Method
    doc.SaveToFile("Convert.PDF",FileFormat.PDF);
    //Launch Document
    System.Diagnostics.Process.Start("Convert.PDF");
}
Build and Run the application. When you click on the Convert button, Coding.Docx i.e our Word Document is converted into PDF Document. You can find the converted PDF document in Bin/Debug/ Directory of your project.
I hope you like this article. Thanks.

3 comments:

  1. Thanks Anoop Kumar Sharma for this tips about word document to PDF. i have read this post before. So I again back to know more about convert audio to text. I hope you are able to give this service. I am waiting for next post.

    ReplyDelete

Subscribe us on YouTube

Subscribe Now

Popular Posts

Contact us

Name

Email *

Message *

Like us on Facebook