How to Convert Word to PDF in WPF

2016-01-15 03:31:19 Written by  support iceblue
Rate this item
(0 votes)

PDF and Word are the two most commonly used files in our daily life, however, sometimes we need to do conversion between them due to their own advantages, disadvantages or our different requirements. Spire.Doc for WPF as a professional word component enables developers to convert Word to PDF easily by invoking the document.SaveToFile() method.

This is the screenshot of the original word document:

How to Convert Word to PDF in WPF

Now follow the steps below:

First, please download and install Spire.Doc correctly, then create a WPF application project and add the Spire.Doc.Wpf.dll as the reference of your project.

Second, drag a button to the MainWindow, double click the button to add following codes to convert Word to PDF.

[C#]
//Load document
Document document = new Document();
document.LoadFromFile("sample.docx");

//convert to PDF
document.SaveToFile("toPDF.PDF",FileFormat.PDF);

//Launch the file
System.Diagnostics.Process.Start("toPDF.PDF");
[VB.NET]
'Load document
Dim document As New Document()
document.LoadFromFile("sample.docx")

'convert to PDF            
document.SaveToFile("toPDF.PDF",FileFormat.PDF)

'Launch the file            
System.Diagnostics.Process.Start("toPDF.PDF")

Effective screenshot:

How to Convert Word to PDF in WPF

Additional Info

  • tutorial_title: Convert Word to PDF in WPF
Last modified on Friday, 24 September 2021 09:52