This example illustrates how to use the XtraPrinting library to adjust the width of an exported ASPxGridView to occupy a single page.
Follow the steps below to fit the grid to one document page:
- Create a PrintableComponentLinkBase object for the grid component.
- Set the Document.AutoFitToPagesWidth property to
1
to fit the grid to one page. - Call the ExportToPdf method to export the document to a stream in PDF format.
using(MemoryStream ms = new MemoryStream()){
PrintableComponentLinkBase pcl = new PrintableComponentLinkBase(new PrintingSystemBase());
pcl.Component = ASPxGridView1;
pcl.Margins.Left = pcl.Margins.Right = 50;
pcl.Landscape = true;
pcl.CreateDocument(false);
pcl.PrintingSystemBase.Document.AutoFitToPagesWidth = 1;
pcl.ExportToPdf(ms);
WriteResponse(this.Response, ms.ToArray(), System.Net.Mime.DispositionTypeNames.Inline.ToString());
}
- Default.aspx (VB: Default.aspx)
- Default.aspx.cs (VB: Default.aspx)