IPrintControl.PrintingSystem Property
Specifies the Printing System used to create and print a document for the link associated with the IPrintControl.
Namespace: DevExpress.XtraPrinting
Assembly: DevExpress.Printing.v20.2.Core.dll
NuGet Packages: DevExpress.Printing.Core, DevExpress.WindowsDesktop.Printing.Core
Declaration
Property Value
Type | Description |
---|---|
PrintingSystemBase | A PrintingSystemBase descendant. |
Example
This example illustrates how to override Printing System commands in code.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/Reporting_how-to-override-commands-in-print-preview-custom-export-e2305
using System;
using System.Windows.Forms;
using System.Drawing.Imaging;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
// ...
private void button1_Click(object sender, EventArgs e) {
// Create a report instance, assigned to a Print Tool.
ReportPrintTool pt = new ReportPrintTool(new XtraReport1());
// Generate the report's document. This step is required
// to activate its PrintingSystem and access it later.
pt.Report.CreateDocument(false);
// Override the ExportGraphic command.
pt.PrintingSystem.AddCommandHandler(new ExportToImageCommandHandler());
// Show the report's print preview.
pt.ShowPreview();
}
public class ExportToImageCommandHandler : ICommandHandler {
public virtual void HandleCommand(PrintingSystemCommand command,
object[] args, IPrintControl printControl, ref bool handled) {
if (!CanHandleCommand(command, printControl)) return;
// Export the document to png.
printControl.PrintingSystem.ExportToImage("C:\\Report.png", ImageFormat.Png);
// Set handled to 'true' to prevent the standard exporting procedure from being called.
handled = true;
}
public virtual bool CanHandleCommand(PrintingSystemCommand command, IPrintControl printControl) {
// This handler is used for the ExportGraphic command.
return command == PrintingSystemCommand.ExportGraphic;
}
}
See Also