PDF documents and electronic books are more and more popular nowadays. People would like to convert their Word or TEXT files to PDF and publish them online. Also, the PDF documents cannot be edited. In order to protect the PDF document, people may encrypt it to prevent others from printing, but the others can view it. And the digital signature can verify or identity owner of PDF documents.

Then, programmers devote themselves to researching how to operate PDF for .NET, for example, create a PDF or convert other format files to PDF, insert tables or images into PDF, merge PDF documents and so on. According to people’s requirements, programmers may develop several tools to realize PDF operation. The most usual tools are convertors to convert Word to PDF.

Actually, Microsoft Word 2007 can realize the conversion between PDF and Word. We just need to click save as and then select the save type as .PDF. Give a specified path to save it. After that, we can find that a new PDF file with contents in the Word document is generated.

However, the convertors are also popular because some people don’t install Word 2007, even don’t install Microsoft Word on computer. And the tools can convert one Word document to PDF very quickly.

Generally speaking, programmers develop the tools by using C#.NET or VB.NET. And now, I want to introduce one method to convert Word to PDF for .NET. It is very simple and programmers don’t need to spend a lot of time on writing code and can work more efficiently.

Please note that: in this method, one third party add-in, Spire.PDF is used.

C#

using Spire.Doc;

namespace FromWord

{

class Program

{

static void Main(string[] args)

{

Document document = new Document(“test.doc”, FileFormat.Doc);

document.SaveToFile(“fromword.pdf”, FileFormat.PDF);

//Launching the Pdf file.

System.Diagnostics.Process.Start(“fromword.pdf”);

}

}

}

VB.NET

Imports Spire.Doc

Namespace FromWord

Friend Class Program

Shared Sub Main(ByVal args() As String)

Dim document As New Document(“test.doc”, FileFormat.Doc)

document.SaveToFile(“fromword.pdf”, FileFormat.PDF)

‘Launching the Pdf file.

Process.Start(“fromword.pdf”)

End Sub

End Class

End Namespace