Why the diagram prints four pages by default? How can I print the diagram in a single page?
Print diagram in single page
The Essential WinForms Diagram printing implementation uses the size of your diagram model and the printer page setting for calculating the number of pages to be rendered. Even though you might have only one page worth of nodes in your diagram model, if the model bounds are larger, the diagram control will attempt to paginate and print the entire model.
To print the diagram in a single page, you have to temporarily modify the size of model.
C#
// The desired page size is 21 x 29.7 centimeters // The margins are of size 1 inch or 25 mm int verticalMargin = 260; int horizontalMargin = 260; // The following units are in millimeters, so convert them to pixels float pageHeight = Diagram.MeasureUnitsConverter.Convert((2970 - (verticalMargin * 2)) / 10, MeasureUnits.Millimeter, MeasureUnits.Pixel); // float pageHeight = bounds.Height; float pageWidth = Diagram.MeasureUnitsConverter.Convert((2100 - (horizontalMargin * 2)) / 10, MeasureUnits.Millimeter, MeasureUnits.Pixel); // Set the model height to twice the page height diagram1.Model.DocumentSize.Height = (int)pageHeight / 2; // Set the model width to page width diagram1.Model.DocumentSize.Width = (int)pageWidth; this.PrintPreview( );
VB
// The desired page size is 21 x 29.7 centimeters // The margins are of size 1 inch or 25 mm Dim verticalMargin As Integer = 260 Dim horizontalMargin As Integer = 260 // The following units are in millimeters, so convert them to pixels Dim pageHeight As Single = Diagram.MeasureUnitsConverter.Convert((2970 - (verticalMargin * 2)) / 10, MeasureUnits.Millimeter, MeasureUnits.Pixel) // float pageHeight = bounds.Height; Dim pageWidth As Single = Diagram.MeasureUnitsConverter.Convert((2100 - (horizontalMargin * 2)) / 10, MeasureUnits.Millimeter, MeasureUnits.Pixel) ' Set the model height to twice the page height diagram1.Model.Size = New SizeF(pageWidth, pageHeight / 2) Me.PrintPreview( )
Conclusion
I hope you enjoyed learning about why the diagram prints four pages by default, how can I print the diagram in a single page.
You can refer to our WinForms Diagram’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms Diagram documentation to understand how to present and manipulate data.
For current customers, you can check out our WinForms components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our WinForms Diagram and other WinForms components.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!