I have two grids that I export. Each grid has a section that is added to the report. The first grid is about 50 columns. Obviously the grid cannot fit on one portrait sized page without being shrunk. The second grid is only 3 columns and can fit on any portrait size page without being shrunk.
The issue I am having is the page size of first grid is wider than the page size of the second grid. Is this something I can fix or is this just how it works. I have added an image of the issue.
Hello ,
Thank you for your feedback. Please let us know if you have any further question on this.
Thank you.
Thanks both of you. I set the page size and margins to be the same size as the largest added section.
The way the exporter works is that it resizes the section to fit all of the columns in the grid. Since the PDF and XPS formats do not support spanning horizontally across pages, the only way to ensure that the grid fits on the page is to make the page wide enough to fit everything.
Since your first grid is wider than your second grid, you could simply export the first grid into a Section, get the PageSize on that second and apply the same PageSize to the second section. Of course, you have to set the PageSize on the second section only AFTER the grid has been exported, since the exporter will set the PageSize during the export process.
One possible way to avoid this issue is to set TargetPapaerSize of UltraGridDocumentExporter to be enough big to fit first grid and then and second grid will be exported to this size. Please use code like :
ultraGridDocumentExporter1.AutoSize = Infragistics.Win.UltraWinGrid.DocumentExport.AutoSize.SizeColumnsToContent;
ultraGridDocumentExporter1.TargetPaperSize = new PageSize(2500, 1000);
Report rep = new Report();
ISection ug1 = rep.AddSection();
ISection ug2 = rep.AddSection();
ultraGridDocumentExporter1.Export(ultraGrid1, ug1);
ultraGridDocumentExporter1.Export(ultraGrid2, ug2);
rep.Publish("Test.pdf", FileFormat.PDF);
Please let me know if you have any further questions.