Click or drag to resize
Pdf Library for .NET

WordToPdf Class

Word to Pdf Converter. This class offers the API needed to convert a Word document (docx, doc, rtf and the other formats of WordFormat) to pdf.
Inheritance Hierarchy
SystemObject
  SelectPdf.UniversalWordToPdf

Namespace: SelectPdf.Universal
Assembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.4
Syntax
public class WordToPdf

The WordToPdf type exposes the following members.

Constructors
 NameDescription
Public methodWordToPdf Initializes an instance of the Word to Pdf converter.
Top
Properties
 NameDescription
Public propertyConversionResult Gets a reference to an object that offers information about the result of the last conversion; null before the first one.
Public propertyFooter Gets a reference to an object that controls the properties of the custom footer of the generated pdf document. Displayed when DisplayFooter is true.
Public propertyHeader Gets a reference to an object that controls the properties of the custom header of the generated pdf document. Displayed when DisplayHeader is true.
Public propertyOptions Gets a reference to an object that controls the conversion process and the generated pdf document properties.
Top
Methods
 NameDescription
Public methodConvertBytes(Byte) Converts a Word document held in memory to pdf. The format is detected from the content (docx family, doc, rtf, WordML); plain text, html and markdown have no signature and must be named with ConvertBytes(Byte, WordFormat).
Public methodConvertBytes(Byte, WordFormat) Converts a Word document held in memory to pdf, reading it as the given format.
Public methodConvertFile(String) Converts the Word document at the given path to pdf. The format is taken from the file extension, or detected from the content when the extension is not one of the known ones.
Public methodConvertFile(String, WordFormat) Converts the Word document at the given path to pdf, reading it as the given format.
Public methodConvertStream(Stream) Converts the Word document read from a stream to pdf. The format is detected from the content (docx family, doc, rtf, WordML); plain text, html and markdown have no signature and must be named with ConvertStream(Stream, WordFormat).
Public methodConvertStream(Stream, WordFormat) Converts the Word document read from a stream to pdf, reading it as the given format.
Top
Remarks
The result of the conversion is a PdfDocument object that can be further modified, saved to memory or into a file on the disk. The conversion runs in-process; no engine is launched. Options, Header and Footer mirror the html converter's, so a document setup written for HtmlToPdf applies here unchanged.
Example
WordToPdf converter = new WordToPdf();
converter.Options.MarginTop = 20;
PdfDocument doc = converter.ConvertFile("report.docx");
doc.Save("report.pdf");
doc.Close();
See Also