What is PDF
PDF (Portable Document Format) is one kind of electronic document format. PDF is the ideal document format to publish electronic document and deliver digital information on internet for it has nothing to do with operation system. PDF file format can package font, format, color and image in a file. Also, it can include hyperlink, voice and video. What's more, it supports long file. And the most important is that it has high security and integration.
Why Convert Word to PDF
However, we can't edit PDF file so that we need to convert PDF to other format file to edit it. As the same, if we don't want others to edit our Word document, we may convert Word to PDF for PDF can remain the format which has been set in Word document. But how should we do to convert Word to PDF with C#/VB.NET?
How to Convert Word to PDF via Spire.Doc
Spire.Doc (Spire.Office) presents you an easy way to convert Word to PDF. In this way, we can convert different Word Doc files to PDF format in a few clicks. Now, follow the simple steps below to convert a Word Doc file to PDF.
Step 1
Create a project through Visual Studio and add Spire.Doc DLL as reference.
Step 2
Load local Word doc file which we need convert to PDF file format. The following code can help us do the job.
Document document = new Document();
document.LoadFromFile(@"D:\Sample.doc");
Step 3
Spire.Doc enables users to convert Word Doc files to most popular file formats including PDF, HTML, EPub, RTF, XML, Text, Dot, etc. Use the following code to choose PDF as output format.
document.SaveToFile("Sample.pdf", FileFormat.PDF);

Step 4
Now, let's write the full code into the project to run it.
[C#]
using System;
using System.Windows.Forms;
using Spire.Doc;
using Spire.Doc.Documents;
namespace toPDF
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//Create word document
Document document = new Document();
document.LoadFromFile(@"D:\Sample.doc");
//Save doc file.
document.SaveToFile("Sample.pdf", FileFormat.PDF);
//Launching the MS Word file.
WordDocViewer("Sample.pdf");
}
private void WordDocViewer(string fileName)
{
try
{
System.Diagnostics.Process.Start(fileName);
}
catch { }
}
}
}
[Visual Basic]
Imports System
Imports System.Windows.Forms
Imports Spire.Doc
Imports Spire.Doc.Documents
Namespace toPDF
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
'Create word document
Dim document As New Document()
document.LoadFromFile("D:\Sample.doc")
'Save doc file.
document.SaveToFile("Sample.pdf", FileFormat.PDF)
'Launching the MS Word file.
WordDocViewer("Sample.pdf")
End Sub
Private Sub WordDocViewer(ByVal fileName As String)
Try
System.Diagnostics.Process.Start(fileName)
Catch
End Try
End Sub
End Class
End Namespace
After running the demo, you may find a PDF document launched on your computer:

Spire.Doc
Spire.Doc is an MS Word component which enables user to perform a wide range of Word document processing tasks directly, such as generate, read, write and modify Word document for .NET and Silverlight.
