Convert Word to PDF Easily with C#/VB.NET

PDF Introduction

PDF (Portable Document Format), developed by Adobe, has been become one of the most frequently used electronic document format now.

Why is PDF so popular? Firstly, PDF has nothing to do with operation system. It means that it can work well on Windows, Mac and Unix. This function enables PDF to be the best choice to publish electronic document and deliver digital information online. Secondly, PDF can reproduce characters, colors and images in original data exactly because it is based on PostScript image model. Therefore, PDF document can give readers a good reading effect.

Convert Word to PDF

Then, how to create PDF document? The method people often use is to convert from other format document, for example, Word to PDF.

In this post, I want to introduce a simple method to convert Word to PDF with C# and VB.NET quickly.

In this method,  a component, Spire.Doc for .NET is used. If you want to use the following code, please download and install this component on your computer firstly and then add Spire.Doc dll file as reference.

Detailed Steps Shown as Following:          

Step 1:

Load file which you want to convert to PDF from your computer by using document.LoadFromFile() method.


            Document document = new Document();



            Dim document As New Document()


Step 2:

Convert this document to PDF by using document.SaveToFile() method. Two parameters passed to this method, file name and file format.


            document.SaveToFile(“ToPDF.PDF”, FileFormat.PDF);


            document.SaveToFile(“ToPDF.PDF”, FileFormat.PDF)

Step 3:

Launch new PDF document.





Result Shown as Following:

Freely Download Spire.Doc for .NET


6 thoughts on “Convert Word to PDF Easily with C#/VB.NET

    • Chaupa says:

      you can do it without a third party dll as follows:

      Imports Word = Microsoft.Office.Interop.Word

      then use this procedure
      Private Sub Word2Pdf(ByVal infile As String, ByVal outfile As String)
      Dim wordApp As Word.Application = Nothing
      wordApp = New Word.Application()
      wordApp.ActiveDocument.ExportAsFixedFormat(outfile, Word.WdExportFormat.wdExportFormatPDF)

      If wordApp IsNot Nothing Then
      End If

      Dim ps As New ProcessStartInfo
      ps.UseShellExecute = True
      ps.FileName = outfile

      End Try
      End Sub

      you can call it as follows:

      This works for me perfectly. A similar method can be used for excel to pdf.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s