C# Word to PDF in C#

Various .NET libraries let you convert Word documents to PDF in C#. However, you often face issues in the converted PDF document, i.e., disturbed layout, slow conversion, etc. So why not try a high-speed and high-fidelity converter that allows you to convert Word DOC to PDF in a few simple steps? This article is going to show you how to perform C# Word to PDF conversion within a couple of steps. Also, you will learn how to customize the conversion process using different options. So let’s begin.

C# Word to PDF Converter Library

Aspose.Words for .NET is a powerful API for creating and manipulating popular Word document formats. The API also provides a simplified way of converting Word documents to PDF with a high degree of fidelity. You can add a reference to Aspose.Words for .NET DLL in your project or install it using NuGet.

PM> Install-Package Aspose.Words

How to Convert Word to PDF in C#

Aspose.Words lets you convert a Word DOC or DOCX to PDF within a couple of steps, as mentioned below:

  • Load the Word document.
  • Save it as PDF to desired location.

And that’s it.

C# Code to Convert a Word DOC to PDF

To convert a Word document to PDF, you’ll have to invoke the Document.Save() method and specify the output file name with the “.pdf” extension. The following are the steps to accomplish that.

  • Load the Word document from the desired location using Document class.
  • Convert Word document to PDF using Document.Save() method.

The following code sample shows how to convert Word DOC to PDF in C#.

Word Document

C# Convert Word to PDF

Converted PDF

Word to PDF programmatically in C#

C# DOC to PDF - Export Selected Pages Only

You can also customize the Word to PDF conversion and convert specific pages only. You can either convert the first N pages or define a range of pages specifying the starting page’s index.

The following code sample shows how to convert 3 pages starting from the second page of a Word DOCX to PDF in C#.

Save Word DOCX to PDF in C# - Set PDF Standard

PDF documents may compliant with different PDF standards such as PDF 1.7, PDF 1.5, PDF/A-1a, etc. Therefore, Aspose.Words for .NET allows specifying the PDF compliance level in Word to PDF conversion. You can specify the compliance level using PdfCompliance enum.

The following C# code sample shows how to set the compliance level in DOCX to PDF conversion.

C# Convert DOCX to PDF with Text/Image Compression

The PDF format supports text and image compression to reduce the size of the document. Since a PDF document could be bulky in size, the compression of its content makes it easy to upload, share, print, etc. So let’s have a look at how to perform text or image compression in DOCX to PDF conversion in C#.

Text Compression Options

The following text compression options are available in PdfTextCompression enum.

  • None: Saving PDF without text compression.
  • Flate: Saving PDF with flate (ZIP) compression.

Image Compression

The following image compression options are available in PdfImageCompression enum.

  • Auto: The API automatically selects the most appropriate compression for every image in the document.
  • Jpeg: Compression to JPEG images (does not support transparency).

The following code sample shows how to convert DOCX to PDF with text and image compression in C#.

Convert Word to a Signed PDF in C#

You can also apply a digital signature to the output PDF while performing Word to PDF conversion. The CertificateHolder class allows you to specify the digital certificate and the password. The PdfDigitalSignatureDetails class allows providing the details of the digital signature such as certificate holder, reason, location and date/time.

The following code sample shows how to convert Word DOC/DOCX to PDF with a digital signature in C#.

C# Word to PDF - Set JPEG Quality

You can also specify the desired JPEG quality you want to get in the converted PDF document using PdfSaveOptions.JpegQuality property. The value of JpegQuality may vary from 0 to 100 where 0 means the worst quality but maximum compression and 100 means the best quality but minimum compression.

The following code sample shows how to set JPEG quality when converting DOCX to PDF in C#.

Export Word DOC to PDF with a Free License

You can get a free temporary license to convert Word documents to PDF without evaluation limitations.


In this article, you have learned how to convert Word documents to PDF in C#. You can use the provided code samples for both DOC and DOCX files. Furthermore, you have seen how to customize the Word to PDF conversion using different options. Also, setting the PDF compliance standard and generating PDF with digital signatures is covered. You can easily integrate the provided code samples and perform Word to PDf conversion from within your applications.

Word Document Converter for C# - Read More

Visit documentation of Aspose.Words for .NET to see the complete set of features offered by the API. For any questions or queries, contact us via our forum.

PowerPoint Presentations to PDF Conversion in JavaPowerPoint Presentations to PDF in C#PDF to Excel in C#
PDF to MS Word Documents in JavaTXT to PDF in C#HTML to Word in C#
Word to Markdown in C#Word to EPUB in C#PDF File to Text in Python
XLSX to JSON in JavaExcel to JSON in JavaDOCX to JSON in Java
DOC to JSON in JavaWord to JSON in JavaTXT to JSON in Java
JSON to PDF in PythonExcel to JSON in JavaTXT to JSON in Python
Word DOC to Markdown in JavaWord DOC DOCX to Markdown in C#Extract Text from Word Documents in Java
Merge MS Word Documents using C# .NETWord DOC to PNG, JPEG, BMP, GIF, or TIFF in C#Word DOC to PNG, JPEG, BMP, GIF, or TIFF in Java