Convert Word to PDF
DynamicPDF Converter can easily convert a Microsoft Word file into a PDF document.
Watch the Video
How to Convert Word to PDF
The easiest way to convert a Word (docx or doc) file to a PDF is by calling the static Convert method of the Converter class. But if advanced options are required, then use the [WordConverter](/docs/dotnet/cete.dynamicpdf.conversion.wordconverter" Word Converter Class") class with WordConversionOptions. The following two examples illustrate.
Steps to Convert DOCX/DOC to PDF (Convert
)
- Use the static
Convert
method of theConverter
class and pass the path to the Word document to convert and the path to the PDF document to create.
Sample Code - C#
Converting a Word document to a PDF is straightforward when you use the Converter.Convert
method. The following one line of code illustrates.
Converter.Convert("sample.docx", "sample.pdf")
Steps to Convert DOCX/DOC to PDF (WordConversionOptions
)
- Create a new
WordConversionOptions
object instance and in the constructor indicate that you are not appending to an existing PDF. - Create a new
WordConverter
object instance and in the constructor specify the path to the Word file and theWordConversionOptions
instance. - Set the top, bottom, left, and right margins.
- Call the
Convert
method on theWordConverter
instance and specify the path to the PDF file to create.
Sample Code - C#
WordConversionOptions options = new WordConversionOptions(false);
options.Author = "John Doe";
options.TopMargin = 144;
options.BottomMargin = 72;
options.LeftMargin = 72;
options.RightMargin = 72;
WordConverter wordDocConverter = new WordConverter("sample.doc", options);
wordDocConverter.Convert("sample.pdf");
GitHub Project
Clone or view the example project at GitHub. This example on this page is in the DocFileConversion.cs file. Examples are provided for both C# and VB.NET.
Getting Started
Get started by installing the NuGet package or referring to the online documentation.
NuGet Package
DynamicPDF Converter is available on NuGet and is part of the ceTe.DynamicPDF.Converter.NET
package. The easiest way to install the DynamicPDF Converter package is by using the Visual Studio Package Manager. However, you can also download it directly from NuGet.
NuGet Package ID:ceTe.DynamicPDF.Converter.NET
DynamicPDF Core Suite Information
More information can be found at the DynamicPDF Converter webpage.