Converting Word docs to PDFs

Let’s learn how to convert a Word document to a PDF using Essential DocIO and Essential PDF.

Essential DocIO renders the contents of a Word document page by page and adds each page to the PDF document using Essential PDF. Use the ConvertToPDF method of the DocToPDFConverter class to convert the WordDocument instance to a PdfDocument instance, and save the PDF document using Essential PDF.

Please note that this conversion support is available only for the following .NET platforms:

  • Windows Forms
  • WPF
  • ASP.NET Web
  • ASP.NET MVC

Note: Doc-to-PDF conversion works only in Full Trust Mode for the above platforms.

Please refer to the following user guide links for more details on Essential DocIO and Essential PDF:

The following code snippet is used to open the Word document with DocIO.

//Opens the Word template document.
WordDocument wordDoc = new WordDocument(fullPath);

These snippets are used to convert the Word document into a PDF.

//Create a new instance to convert the Word document.
DocToPDFConverter converter = new DocToPDFConverter();
//Convert the Word document into a PDF document.
PdfDocument pdfDoc = converter.ConvertToPDF(wordDoc);

You can save the converted PDF document into a file system using Essential PDF.

The following code snippet is used to save the converted PDF document into a file system.

//Save the PDF file.
pdfDoc.Save("DoctoPDF.pdf");

The following screenshot illustrates the input Word template document.

The next screenshot shows the final PDF document converted from the Word template.

You can save the converted PDF document to the file system or file stream in order to store it in a database. It can also be streamed to the client browser in web applications.

Doc-to-PDF conversion supports the following Word elements:

  • Paragraph and character formatting.
  • Multicolumn text.
  • Headers and footers.
  • Bulleted, numbered, and multilevel lists.
  • Images.
  • Tables (both simple and nested).
  • Table styles for .docx formats.
  • Breaks (page, section, line break, etc.).
  • OLE Objects.
  • Textboxes.
  • Page settings and background images.
  • Document properties.
  • Tables of contents.
  • Bookmarks.
  • Hyperlinks.
  • Footnotes and endnotes.
  • AutoShapes for .docx formats.

The following unsupported elements will not be preserved in the generated PDF document.

Comments. Shapes. Dynamic fields. Charts.

For more information on Doc-to-PDF conversion, please refer to the following user guide link:

http://help.syncfusion.com/ug/asp.net/docio/default.htm#!documents/doctopdf.htm

Loading