Is it possible to shrink a grid's width so it will fit the paper size specified during an export?
This is a code snippet that does all the heavy lifting. As you can see I'm setting both the exporter AutoSize property and the report FitToMargins property and I continue to get the columns that do not fit on the page cut off. Please advise.
public void Export() { if (grid == null) throw new ArgumentNullException("grid"); if (pageSettings == null) throw new ArgumentNullException("pageSettings"); report = new Report(); report.Preferences.Printing.FitToMargins = true; SetupReportInfo(report); ISection section = SetupDefaultSection(report); SetupHeader(section); SetupFooter(section); using (var exporter = new UltraGridDocumentExporter()) { // Make sure we export the grid in the same orientation as the report if(pageSettings.Landscape) exporter.TargetPaperOrientation = PageOrientation.Landscape; else exporter.TargetPaperOrientation = PageOrientation.Portrait; exporter.TargetPaperSize = GetPageSize(pageSettings.PaperSize.Kind.ToString()); // This translates the MS PaperSize to the Infragistics PaperSize exporter.AutoSize = AutoSize.SizeColumnsAndRowsToContent; // this shrinks the grids and columns to the size of the content exporter.UseFileBuffer = true; exporter.Export(grid, section); } report.Publish(filename, FileFormat.PDF); OpenReport(filename); }
I am using the Infragistics.Documents.Reports.Report.Report() class to set up the PDF export. I am also using the UltraGridDocumentExporter to perform the actual export. I have set the report.Preferences.Printing.FitToMargins = true; I am also setting the exporter.AutoSize to AutoSize.SizeColumnsAndRowsToContent. I cannot set the TargetPaperSize to autosize because the customer controls the size of the paper they want to export to.
I am not using the UltraGridPrintDocument class at this point. Is that a better option?
I have a user defined UltraGrid that I need to export to a PDF. There are custom headers and footers that need to be added to the PDF document. That was pretty straightforward using the DocumentExporter and Reports classes, I need to tell the exporter and/or the report not to cut off columns that don't fit.
Hello Kenneth,
Could you please give us more details about your scenario to export the grid in PDF file, because there are few different approaches.
Option 1: using ultraGridDocumentExporter1:
In this case you could set AutoSize = SizeColumnsandRowsToContent property
Option 2: using Documents.Report:
In this case you could modify the settings below :
report.Preferences.Printing.PaperSize = Infragistics.Documents.Reports.Report.Preferences.Printing.PaperSize.Auto;
report.Preferences.Printing.PaperOrientation = Infragistics.Documents.Reports.Report.Preferences.Printing.PaperOrientation.Auto;
report.Preferences.Printing.FitToMargins = true;
Infragistics.Documents.Reports.Report.Grid.IGridColumn column = grid.AddColumn();
column.Width =new Infragistics.Documents.Reports.Report.RelativeWidth(20);
column = grid.AddColumn();
column.Width =new Infragistics.Documents.Reports.Report.FixedWidth(100);
Option 3: using UltraGirdPrintDocument:
In this case you could try to set
ultraGridPrintDocument1.FitWidthToPages = 1;
Let me know if you have any questions.