We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I add Print/Print Preview to my Essential Diagram application?

Platform: WinForms |
Control: Diagram |
Published Date: April 30, 2011 |
Last Revised Date: July 10, 2014


The following code sample shows how you can add Print and Print/Preview support to your Essential Diagram application using the CreatePrintDocument Method:


//Set up Print private void Print() {  System.Drawing.Printing.PrintDocument printDoc = this.diagram1.CreatePrintDocument();  PrintDialog printDlg = new PrintDialog();  printDlg.Document = printDoc;  if (printDlg.ShowDialog(this) == DialogResult.OK)  {   printDoc.Print();  } }

//Set up Print Preview private void PrintPreview() {  System.Drawing.Printing.PrintDocument printDoc = this.diagram1.CreatePrintDocument();  PrintPreviewDialog printPreviewDlg = new PrintPreviewDialog();  printPreviewDlg.Document = printDoc;  printPreviewDlg.ShowDialog(this); }

//Print Preview Button private void printpreviewbutton_Click(object sender, System.EventArgs e) {  this.PrintPreview(); }

//Print Button private void printtbutton_Click(object sender, System.EventArgs e) {  this.Print(); }

[VB.NET] 'Set up Print Private  Sub Print()  Dim printDoc As System.Drawing.Printing.PrintDocument =  Me.diagram1.CreatePrintDocument()  Dim printDlg As PrintDialog =  New PrintDialog()  printDlg.Document = printDoc  If printDlg.ShowDialog(Me) = DialogResult.OK Then   printDoc.Print()  End If End Sub   'Set up Print Preview Private  Sub PrintPreview()  Dim printDoc As System.Drawing.Printing.PrintDocument =  Me.diagram1.CreatePrintDocument()  Dim printPreviewDlg As PrintPreviewDialog =  New PrintPreviewDialog()  printPreviewDlg.Document = printDoc  printPreviewDlg.ShowDialog(Me) End Sub   'Print Preview Button Private  Sub printpreviewbutton_Click(ByVal sender As Object, ByVal e As System.EventArgs)  Me.PrintPreview() End Sub   'Print Button Private  Sub printtbutton_Click(ByVal sender As Object, ByVal e As System.EventArgs)  Me.Print() End Sub

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon