RichEditControl.ExportToPdf(String) Method
Exports the document content to the specified file path in PDF format.
Namespace: DevExpress.XtraRichEdit
Assembly: DevExpress.XtraRichEdit.v19.1.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
fileName | String | A String which specifies the file name (including the full path) for the created PDF file. |
Remarks
PDF Export features and limitations are detailed in the Export to PDF document.
To print the document, use the RichEditControl.Print method.
Example
Note
A complete sample project is available at: The RichEditControl’s common API
The following code loads the sample document, specifies export options using the PdfExportOptions settings and exports it to PDF. It invokes the default PDF viewer to display the resulting document.
The RichEditControl instance is passed to the BarItem.ItemClick event handler using the BarItem.Tag property.
static void buttonCustomAction_ItemClick_PDF(object sender, ItemClickEventArgs e) {
RichEditControl richEdit = e.Item.Tag as RichEditControl;
richEdit.LoadDocument("Documents\\Grimm.docx");
//Set the required export options:
DevExpress.XtraPrinting.PdfExportOptions options = new DevExpress.XtraPrinting.PdfExportOptions();
options.DocumentOptions.Author = "Mark Jones";
options.Compressed = false;
options.ImageQuality = DevExpress.XtraPrinting.PdfJpegImageQuality.High;
//Export the document to the file:
richEdit.ExportToPdf("resultingDocument.pdf", options);
//Export the document to the file stream:
using (FileStream pdfFileStream = new FileStream("resultingDocumentFromStream.pdf", FileMode.Create)) {
richEdit.ExportToPdf(pdfFileStream, options);
}
System.Diagnostics.Process.Start("resultingDocument.pdf");
}