We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to convert Word to PDF using C# and VB.NET

Platform: WinForms |
Control: PDF |
Published Date: October 31, 2018 |
Last Revised Date: March 5, 2020

Syncfusion Essential PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can convert Word document to PDF in C# and VB.NET.

Steps to convert word document to PDF programmatically:

  1. Create a new C# console application project.

Create console application

  1. Install the Syncfusion.DocToPDFConverter.WinForms NuGet packages as reference to your .NET Framework application from NuGet.org.

NuGet package reference

  1. Include the following namespaces in the Program.cs file.

C#

using Syncfusion.Pdf;
using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
using Syncfusion.DocToPDFConverter;

 

VB.NET

Imports Syncfusion.Pdf
Imports Syncfusion.DocIO
Imports Syncfusion.DocIO.DLS
Imports Syncfusion.DocToPDFConverter

 

  1. Use the following code snippet to convert Word document to PDF.

C#

//Load an existing Word document
WordDocument wordDocument = new WordDocument("Sample.docx", FormatType.Docx);
//Create an instance of DocToPDFConverter
DocToPDFConverter converter = new DocToPDFConverter();
//Convert Word document into PDF document
PdfDocument pdfDocument = converter.ConvertToPDF(wordDocument);
//Save the PDF file
pdfDocument.Save("WordtoPDF.pdf");
//Close the instance of document objects
pdfDocument.Close(true);
wordDocument.Close();
//This will open the PDF file so, the result will be seen in default PDF viewer
System.Diagnostics.Process.Start("WordtoPDF.pdf");

 

VB.NET

'Load an existing Word document
Dim wordDocument As WordDocument = New WordDocument(("Sample.docx"), FormatType.Docx)
'Create an instance of DocToPDFConverter
Dim converter As DocToPDFConverter = New DocToPDFConverter
'Convert Word document into PDF document
Dim pdfDocument As PdfDocument = converter.ConvertToPDF(wordDocument)
'Save the PDF file
pdfDocument.Save("WordtoPDF.pdf")
'Close the instance of document objects
pdfDocument.Close(True)
wordDocument.Close()
'This will open the PDF file so, the result will be seen in default PDF viewer
System.Diagnostics.Process.Start("WordtoPDF.pdf")

 

A complete working sample can be downloaded from WordToPDFSample.zip

By executing the program, you will get the PDF document as follows.

Output document screenshot

Take a moment to peruse the documentation for working with document conversion, where you will find other options like Excel, RTF, TIFF, and XPS to PDF conversion.

An online sample link demonstrating the use of Word to PDF conversion.

Refer here to explore the rich set of Syncfusion Essential PDF features.

Note:

Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.

 

See Also:

Convert Word to PDF in UWP

Convert Word to PDF in ASP.NET Core

Convert Word to PDF in Xamarin

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment
Comments
Jordan Capa
Apr 23, 2019

Thanks for the very easy steps on how to conver word to pdf using c# and vb.net, it really helped me a lo! Just in case you want or need a software that is very fast and easy to use i recommend using ZetPDF.com. It will help you a lot!

Reply

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon