How to: Utilize a Print Preview Dialog to Adjust Margins in the RichEditControl Document
This example illustrates how to handle the PrintingSystemBase.AfterMarginsChange event to apply margin settings adjusted in the Print Preview dialog to the document loaded in the RichEditControl. The document is printed via the PrintableComponentLink and the PrintTool.ShowPreviewDialog method is used to display the Print Preview window.
void PrintingSystem_AfterMarginsChange(object sender, MarginsChangeEventArgs e) {
// Change document margins in the source RichEditControl
SectionMargins margins = this.richEditControl1.Document.Sections[0].Margins;
switch (e.Side) {
case MarginSide.Left:
margins.Left = Units.HundredthsOfInchToDocuments((int)e.Value);
break;
case MarginSide.Right:
margins.Right = Units.HundredthsOfInchToDocuments((int)e.Value);
break;
case MarginSide.Top:
margins.Top = Units.HundredthsOfInchToDocuments((int)e.Value);
break;
case MarginSide.Bottom:
margins.Bottom = Units.HundredthsOfInchToDocuments((int)e.Value);
break;
default:
break;
}
link.CreateDocument();
}