Convert a Document to PDF
The ability to easily and reliably convert documents from one format to another is a key feature of Aspose.Words. One of the most popular formats for converting is PDF – a fixed-layout format, which preserves the original appearance of a document during its rendering on various platforms. The “rendering” term is used in Aspose.Words to describe the process of converting a document into a file format that is paginated or has the concept of pages.
Convert a Word Document to PDF
Conversion from Word to PDF is a rather complex process that requires several stages of calculation. Aspose.Words layout engine mimics the way the Microsoft Word’s page layout engine works, making PDF output documents look as close as possible to what you can see in Microsoft Word.
With Aspose.Words you can programmatically convert a document from Word formats, such as DOC or DOCX, to PDF without using Microsoft Office. This article explains how to perform this conversion.
Convert DOC or DOCX to PDF
Converting from the DOC or DOCX document format into the PDF format in Aspose.Words is very easy and can be accomplished with just two lines of code that:
- Load your document into a Document object using one of its constructors by specifying the document name with its format extension.
- Invoke one of the Document.save methods on the Document object and specify the desired output format as PDF by entering a file name with the “.PDF” extension.
The following code example shows how to convert a document from DOCX into PDF using the save method:
You can download the template file of this example from Aspose.Words GitHub.
Sometimes it is necessary to specify additional options, which can affect the result of saving a document as a PDF. These options can be specified by the use of the PdfSaveOptions class, containing properties that determine how the PDF output will be displayed.
Note that with the same technique, you can convert any flow-layout format document to PDF format.
Convert to Various PDF Standards
Aspose.Words provides the PdfCompliace enumeration to support the conversion of DOC or DOCX into various PDF format standards (such as PDF 1.7, PDF 1.5, etc.).
- The article “Rendering” for more information on the fixed-page and flow-layout formats
- The article “Converting to Fixed-page Format” for more information on the page layout
- The article “Specify Rendering Options When Converting to PDF” for more information on using the PdfSaveOptions class