Syncfusion Feedback

Word to PDF Conversion Using the Syncfusion .NET Word Library

The Syncfusion® .NET Word Library offers powerful APIs for programmatically converting Word documents to PDF with minimal code in C#, without Microsoft Word or interop dependencies.

Watch this video to learn how to convert a Word document to PDF using the Syncfusion .NET Word Library.

Watch the video

Convert Word to PDF using C#

Learn how to convert Word documents to PDF programmatically using C# with the Syncfusion .NET Word Library. This guide demonstrates accurate conversion from Word to PDF format with minimal code.

Step 1: Create a new project

Start by creating a new C# Console Application project.

Step 2: Install the NuGet package

Add the Syncfusion.DocIORenderer.Net.Core package to your project from NuGet.org.

Step 3: Add required namespaces to convert Word to PDF

Add the following namespaces to your Program.cs file:

using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
using Syncfusion.DocIORenderer;
using Syncfusion.Pdf;
using System.IO;

Step 4: Open a Word document

Open an existing Word document for conversion.

FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open);
//Load an existing Word document
WordDocument wordDocument = new WordDocument(fileStream, FormatType.Automatic);

Step 5: Convert Word document to PDF

Convert the Word document into a PDF document using the DocIORenderer.

//Create an instance of DocIORenderer
DocIORenderer renderer = new DocIORenderer();
//Convert Word document into PDF document
PdfDocument pdfDocument = renderer.ConvertToPDF(wordDocument);

Step 6: Save the PDF file

Save the converted PDF document to a file stream.

Run

//Save the PDF file to file system   
FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/WordToPDF.pdf"), FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
pdfDocument.Save(outputStream);
// Close resources explicitly
outputStream.Close();
pdfDocument.Close();
wordDocument.Close();
fileStream.Close();

Get started quickly by downloading the installer and checking license information on the Downloads page.

Syncfusion .NET Word Library Resources

Explore these resources for comprehensive guides, knowledge base articles, insightful blogs, and ebooks.