.NET Word Examples
- Create Word Document
- Perform Mail Merge
- Manage Bookmarks
- Find and Replace Text
- Format Tables
- Split Word Documents
- Merge Multiple Word Documents
- Fill and Manage Form Fields
- Generate and Update Table of Contents
- Compare Word Documents
- Encrypt and Decrypt Documents with Password
- Convert Word Documents to PDF
- Convert Word Documents to Images
- Word-HTML Conversions
- Word-Markdown Conversions
- Word-Text Conversions
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.
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.
//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();GitHub project
NuGet installation
Get started quickly by downloading the installer and checking license information on the Downloads page.
Table of contents
Explore these resources for comprehensive guides, knowledge base articles, insightful blogs, and ebooks.
Learning
Technical Support
