Print a Document
- 2 minutes to read
Users can print out the current document using a built-in UI command or the standard keyboard shortcut (CTRL+P). To disable this functionality, set the control’s Printing property to Disabled or Hidden.
To print out a document from code, use the filePrint Command.
richEdit.commands.filePrint.execute();
In both cases, the control leverages the browser’s Print dialog to complete the task.
Print Modes
The ASPxRichEdit control supports three print modes:
Server PDF Mode (ServerPdf),
Client HTML Mode (ClientHtml),
Client PDF Mode (ClientPdf),
Server PDF Printing (default)
ASPxRichEdit requests the printed document from the server. The server exports the document to a PDF file and sends the result to the client. On the client, the control invokes the Print dialog for the PDF file.
Note
The printed document’s layout may differ from what you see on screen.
Client HTML Printing
ASPxRichEdit renders the current document’s markup into a blank browser tab and calls the browser’s Print dialog. This strategy produces a WYSIWYG output.
To enable the Client HTML Mode set the PrintMode property to ClientHtml.
ASPxRichEdit.Settings.Printing.PrintMode = PrintMode.ClientHtml;
Note
- The client mode can be slower than server mode when you print large documents.
- To prevent content offset, ensure that the same page format is set in both the document and the printer.
Client PDF Printing
ASPxRichEdit exports the current document to PDF on the client side, so that the PDF layout mirrors the layout in a browser. Then the control invokes the Print dialog for the PDF file.
To enable the Client PDF Mode, set the PrintMode property to ClientPdf.
ASPxRichEdit.Settings.Printing.PrintMode = PrintMode.ClientPdf;
Note
The client-side PDF export requires you to provide a list of available fonts and their sources to be uploaded to the client. For more information, see the Font Management topic.