DocToPDFConverter Class
This class provides support for converting WordDocument into an PDF Document.
Inheritance
Implements
Inherited Members
Namespace: Syncfusion.DocToPDFConverter
Assembly: Syncfusion.DocToPDFConverter.Base.dll
Syntax
public class DocToPDFConverter : IDisposable
Remarks
This class is supported on Windows Forms, WPF, ASP.NET and ASP.NET MVC platforms only.
Examples
This example converts the specified Word Document in to PDF Document.
//Loads an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Instantiation of DocToPDFConverter for Word to PDF conversion
DocToPDFConverter converter = new DocToPDFConverter();
//Converts Word document into PDF document
PdfDocument pdfDocument = converter.ConvertToPDF(wordDocument);
//Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf");
//Releases all resources used by the object.
converter.Dispose();
//Closes the instance of document objects
pdfDocument.Close(true);
wordDocument.Close();
'Loads an existing Word document
Dim wordDocument As New WordDocument("Template.docx", FormatType.Docx)
'Instantiation of DocToPDFConverter for Word to PDF conversion
Dim converter As New DocToPDFConverter()
'Converts Word document into PDF document
Dim pdfDocument As PdfDocument = converter.ConvertToPDF(wordDocument)
'Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf");
'Releases all resources used by the object.
converter.Dispose();
'Closes the instance of document objects
pdfDocument.Close(true);
wordDocument.Close();
Constructors
DocToPDFConverter()
Initializes a new instance of the DocToPDFConverter class.
Declaration
public DocToPDFConverter()
Remarks
This constructor is supported on Windows Forms, WPF, ASP.NET and ASP.NET MVC platforms only.
Examples
This example converts the specified Word Document in to PDF Document.
//Loads an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Instantiation of DocToPDFConverter for Word to PDF conversion
DocToPDFConverter converter = new DocToPDFConverter();
//Converts Word document into PDF document
PdfDocument pdfDocument = converter.ConvertToPDF(wordDocument);
//Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf");
//Releases all resources used by the object.
converter.Dispose();
//Closes the instance of document objects
pdfDocument.Close(true);
wordDocument.Close();
'Loads an existing Word document
Dim wordDocument As New WordDocument("Template.docx", FormatType.Docx)
'Instantiation of DocToPDFConverter for Word to PDF conversion
Dim converter As New DocToPDFConverter()
'Converts Word document into PDF document
Dim pdfDocument As PdfDocument = converter.ConvertToPDF(wordDocument)
'Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf");
'Releases all resources used by the object.
converter.Dispose();
'Closes the instance of document objects
pdfDocument.Close(true);
wordDocument.Close();
Properties
IsCanceled
Gets a value indicating whether this conversion has been canceled.
Declaration
public bool IsCanceled { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
This method is supported on Windows Forms, WPF, ASP.NET and ASP.NET MVC platforms only.
Settings
Gets or sets the quality.
Declaration
public DocToPDFConverterSettings Settings { get; set; }
Property Value
Type |
---|
DocToPDFConverterSettings |
Remarks
This property is supported on Windows Forms, WPF, ASP.NET and ASP.NET MVC platforms only.
Methods
ConvertToPDF(WordDocument)
Converts the specified WordDocument to PDF.
Declaration
public PdfDocument ConvertToPDF(WordDocument wordDocument)
Parameters
Type | Name | Description |
---|---|---|
WordDocument | wordDocument | The word document. |
Returns
Type | Description |
---|---|
PdfDocument | The PdfDocument. |
Remarks
This method is supported on Windows Forms, WPF, ASP.NET and ASP.NET MVC platforms only. If running the application by hosting in Azure environment, EnableFastRendering is enabled automatically.
Examples
This example converts the specified Word Document in to PDF Document.
//Loads an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Instantiation of DocToPDFConverter for Word to PDF conversion
DocToPDFConverter converter = new DocToPDFConverter();
//Converts Word document into PDF document
PdfDocument pdfDocument = converter.ConvertToPDF(wordDocument);
//Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf");
//Releases all resources used by the object.
converter.Dispose();
//Closes the instance of document objects
pdfDocument.Close(true);
wordDocument.Close();
'Loads an existing Word document
Dim wordDocument As New WordDocument("Template.docx", FormatType.Docx)
'Instantiation of DocToPDFConverter for Word to PDF conversion
Dim converter As New DocToPDFConverter()
'Converts Word document into PDF document
Dim pdfDocument As PdfDocument = converter.ConvertToPDF(wordDocument)
'Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf");
'Releases all resources used by the object.
converter.Dispose();
'Closes the instance of document objects
pdfDocument.Close(true);
wordDocument.Close();
ConvertToPDF(Stream)
Converts to PDF.
Declaration
public PdfDocument ConvertToPDF(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream. |
Returns
Type | Description |
---|---|
PdfDocument | The PdfDocument. |
Remarks
This method is supported on Windows Forms, WPF, ASP.NET and ASP.NET MVC platforms only. If running the application by hosting in Azure environment, EnableFastRendering is enabled automatically.
Examples
This example converts the specified Word Document in to PDF Document.
//Loads an existing Word document
Stream fileStream = new FileStream("Template.docx", FileMode.Open, FileAccess.Read, FileShare.Read);
//Instantiation of DocToPDFConverter for Word to PDF conversion
DocToPDFConverter converter = new DocToPDFConverter();
//Converts the specified WordDocument to PDF.
PdfDocument pdfDocument = converter.ConvertToPDF(fileStream);
//Save the document in the given name and PDF format
pdfDocument.Save("WordtoPDF.pdf");
//Releases all resources used by the object.
converter.Dispose();
//Closes the instance of document objects
fileStream.Close();
pdfDocument.Close(true);
//Loads an existing Word document
Dim fileStream As Stream = New FileStream("Template.docx", FileMode.Open, FileAccess.Read, FileShare.Read)
'Instantiation of DocToPDFConverter for Word to PDF conversion
Dim converter As New DocToPDFConverter()
'Converts Word document into PDF document
Dim pdfDocument As PdfDocument = converter.ConvertToPDF(fileStream)
'Save the document in the given name and PDF format
pdfDocument.Save("WordtoPDF.pdf");
'Releases all resources used by the object.
converter.Dispose();
'Closes the instance of document objects
fileStream.Close();
pdfDocument.Close(true);
ConvertToPDF(String)
Converts the specified WordDocument to PDF.
Declaration
public PdfDocument ConvertToPDF(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | Name of the file. |
Returns
Type | Description |
---|---|
PdfDocument | The PdfDocument. |
Remarks
This method is supported on Windows Forms, WPF, ASP.NET and ASP.NET MVC platforms only. If running the application by hosting in Azure environment, EnableFastRendering is enabled automatically.
Examples
This example converts the specified Word Document in to PDF Document.
//Instantiation of DocToPDFConverter for Word to PDF conversion
DocToPDFConverter converter = new DocToPDFConverter();
//Converts the specified WordDocument to PDF.
PdfDocument pdfDocument = converter.ConvertToPDF("Template.docx");
//Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf");
//Releases all resources used by the object.
converter.Dispose();
//Closes the instance of document objects
pdfDocument.Close(true);
'Creates an instance of the DocToPDFConverter
Dim converter As New DocToPDFConverter() for Word to PDF conversion
'Instantiation of DocToPDFConverter
Dim pdfDocument As PdfDocument = converter.ConvertToPDF("Template.docx")
'Save the document in the given name and PDF format
pdfDocument.Save("WordtoPDF.pdf");
'Releases all resources used by the object.
converter.Dispose();
'Closes the instance of document objects
pdfDocument.Close(true);
Dispose()
Releases all resources used by the object.
Declaration
public void Dispose()
Remarks
This method is supported on Windows Forms, WPF, ASP.NET and ASP.NET MVC platforms only.
Examples
This example converts the specified Word Document in to PDF Document.
//Loads an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Instantiation of DocToPDFConverter for Word to PDF conversion
DocToPDFConverter converter = new DocToPDFConverter();
//Converts Word document into PDF document
PdfDocument pdfDocument = converter.ConvertToPDF(wordDocument);
//Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf");
//Releases all resources used by the object.
converter.Dispose();
//Closes the instance of document objects
pdfDocument.Close(true);
wordDocument.Close();
'Loads an existing Word document
Dim wordDocument As New WordDocument("Template.docx", FormatType.Docx)
'Instantiation of DocToPDFConverter for Word to PDF conversion
Dim converter As New DocToPDFConverter()
'Converts Word document into PDF document
Dim pdfDocument As PdfDocument = converter.ConvertToPDF(wordDocument)
'Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf");
'Releases all resources used by the object.
converter.Dispose();
'Closes the instance of document objects
pdfDocument.Close(true);
wordDocument.Close();