
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
- How to Convert Word to PDF in C#
- Convert Word DOCX to PDF in C#
- Convert desired pages of Word to PDF in C#
- Word to PDF conversion with a particular PDF Standard
- Export Word to PDF with image/text compression
- C# DOCX/DOC to PDF with a digital signature
- Save Word DOC as PDF with desired JPEG quality
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

Converted PDF

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.
Conclusion
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.