Skip to content

DevExpress-Examples/asp-net-web-forms-grid-fit-exported-document-to-page

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grid View for ASP.NET Web Forms - How to fit exported document to page

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:

  1. Create a PrintableComponentLinkBase object for the grid component.
  2. Set the Document.AutoFitToPagesWidth property to 1 to fit the grid to one page.
  3. 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());
}

Files to Review