C# Word to PDF Conversion
Why Use C# to Convert Word to PDF
Nowadays, most of electronic books, materials and even magazines are created with PDF. PDF documents are very popular in different areas. Even though, Microsoft Word allows users to save Word document as PDF format, developers/programmers like use C# to convert Word to PDF because they don't need install Microsoft Word and open a Word document in this way. In the market, some .NET components for developers are able to convert Word to PDF with C#.
C# Word to PDF Conversion with .NET Component
Spire.Doc is a .NET component for developers which can use C# to convert Word to PDF with some special features. Download Spire.Doc, install on your system and follow the simple steps below to do C# Word to PDF conversion.
Friendly Reminder: Please make sure Spire.Doc and Visual Studio are correctly installed on system.
Step 1 Create a Project in Visual Studio
Create a C# project in Visual Studio and Add Spire.Doc dll as reference. The default setting of Spire.Doc dll is placed under "C:\Program Files\e-iceblue\Spire.Doc\Bin”. Select assembly Spire.Doc.dll and click OK to add it to the project.
using System;
using Spire.Doc;
namespace DocToPdf
{
class Program
{
static void Main(string[] args)
{
}
}
}
Step 2 Load Word Document which we need convert to PDF
Put the word document into the project file folder and use the following code to load it into the project.
Document doc = new Document();
doc.LoadFromFile(@"..\..\Test.doc",FileFormat.Doc);
Step 3 Save and Preview
In the code below, choose the file format as PDF and give it a name. In addition, Spire.Doc allows developers to choose the output file format as rtf, html, text, xml, ePub, dot, etc.
doc.SaveToFile(@"..\..\Test.pdf",FileFormat.PDF);
System.Diagnostics.Process.Start(@"..\..\Test.pdf");
Recently, Spire.Doc released a new version (V4.2) which allows users to set output image quality in PDF file. This function can help developers to reduce output PDF file size.
As a professional .NET component, Spire.Doc 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. It supports C#, VB.NET, ASP.NET, ASP.NET MVC and Silverlight. Click to learn more…
As a professional .NET component, Spire.Doc 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. It supports C#, VB.NET, ASP.NET, ASP.NET MVC and Silverlight. Click to learn more…