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:
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: