This sample shows you how to print a grid on a single page. It derives a GridPrintDocumentAdv class in order to handle the printing of multiple grids across various pages.
Features:
Drawing a full-size grid to a large bitmap and then drawing the bitmap scaled to fit the output page
Various properties that can be used to print the Grid
Columns that can be specified to fit in a single page
Headers and footers that can be added with the events DrawGridPrintHeader and DrawGridPrintFooter
Interactive Features:
Declare an object for the class GridPrintDocumentAdv with its constructor parameter as the grid-control object.
Syncfusion.GridHelperClasses.GridPrintDocumentAdv pd = new Syncfusion.GridHelperClasses.GridPrintDocumentAdv(this.gridGroupingControl1); Bitmap gridBM = new Bitmap(gridWidth, gridHeight); / Can spacify the length of the margin. pd.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(25, 25, 25, 25); //The height of the margin can be zero if it has to be hidden pd.HeaderHeight = 70; pd.FooterHeight = 50;
Here is the code snippet that shows how to create your own header and footer.
//Events for both header and footer pd.DrawGridPrintHeader += new Syncfusion.GridHelperClasses.GridPrintDocumentAdv.DrawGridHeaderFooterEventHandler(pd_DrawGridPrintHeader); pd.DrawGridPrintFooter += new Syncfusion.GridHelperClasses.GridPrintDocumentAdv.DrawGridHeaderFooterEventHandler(pd_DrawGridPrintFooter); //This can be spacified to whether the columns should be fit in single page. pd.ScaleColumnsToFitPage = true;
The following is an image of the print preview dialog box.