Tuesday, May 6, 2014

How to Convert Word to PDF for Free in C#

This is an all-in-one solution to convert Word to PDF. Within this solution, you can either create a word from scratch or load a word template from folder, and then edit the document as you like; finally you can effortlessly convert word to PDF in C#, VB.NET. The conversion can be doc or docxto PDF.
Free Spire.Doc for .NET is a Community Edition of the Spire.Doc for .NET. It is a free.NET word library which enables users to directly manage word editing without Microsoft Word being installed, after the editing, you can convert the document to PDF in 2 steps.

Below is an effective screenshot of the document which will be converted to PDF. At the end of this post, you can find the target PDFdocument.
Now download the free version of Spire.Doc for .NET and convert word to PDF for personal use or evaluation. The whole process of converting word to PDF in C#, VB.NET can be described as 2 simple steps.
1. Declare a document and load document which you prepare by using ocument.LoadFromFile() method. The parameter passed to this method is file name string.
2. Save Word document as PDF by using document.SaveToFile() method. Parameters passed to this method is file name string and file format. The file format must be PDF.
[C#]
using System;
using Spire.Doc;
usingSpire.Doc.Documents;
namespaceDoctoPDF

{
classProgram
    {
staticvoid Main(string[] args)
{

Documentdocument = newDocument();
document.LoadFromFile("Word.doc"); 

//Convert Word to PDF 
document.SaveToFile("toPDF.PDF", FileFormat.PDF);

//Launch Document 
System.Diagnostics.Process.Start("toPDF.PDF"); 
        }
    }
}
[VB]
mports System

Imports Spire.Doc 

ImportsSpire.Doc.Documents

NamespaceDoctoPDF
FriendClasstoPDF
SharedSubMain(ByValargs() AsString)

'Load Document 
Dim document AsNewDocument()
document.LoadFromFile("E:\work\documents\TestSample.docx")

'Convert Word to PDF 
document.SaveToFile("toPDF.PDF", FileFormat.PDF)

'Launch Document 

System.Diagnostics.Process.Start("toPDF.PDF")

EndSub

EndClass

EndNamespace
After running the demo, you may find a PDF document launched on your computer:


13 comments:

  1. Why don't you give this JPG to PDF converter a try. You must try this JPG to PDF converter and you will be surprised

    ReplyDelete
  2. How to Convert Word to PDF in C#, another .net document converter library, supports convert word to pdf/html/text, convert pdf to image/text and so on.

    ReplyDelete
  3. The Free Spire.Doc for .NET product provided by the blogger is great, but I don't know if it can be reversed, support convert pdf to text c#, and support C# pdf to image.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Awesome article…..truly appreciated thanks keep sharing convert word to html

    ReplyDelete
  6. merely a smiling visitant right here to allocation the excessive regard (:, btw top notch fashion. convert to word

    ReplyDelete
  7. free html to pdf converter

    HTML to PDF Converter | Convert from html to pdf online, using SelectPdf web to pdf convert

    https://selectpdf.com/category/html-to-pdf/

    ReplyDelete
  8. A much-needed list! There are often a lot of documents I need to convert due to the nature of my work and often the servers don’t respond or crash after a few processes. Now I can engage a few of these together to get my work done on time. As for the PDF to doc conversion I used ByteScout

    ReplyDelete
  9. Nice blog.This Batch Word to RTF converter is an indispensable tool for those who have to convert .DOC format file to .RTF format files in bulk on day to day basis. word to rtf converter

    ReplyDelete
  10. To convert a Word document to PDF for free in C, you can utilize libraries like iTextSharp or Microsoft's Office Interop. Does Streaming Improve iTextSharp enables programmatic PDF creation and manipulation.

    ReplyDelete