I'm trying to export to PDF and produce the same results as we get from the UltraGridPrintDocument when printing. I can produce a PDF using the UltraGridDocumentExporter (as below), but I can't seem to control the margins, or the size of the grid (i.e. not just scaling to fit one page). Also, if I try to export a large grid I get an 'OutOfMemoryException'.
Infragistics.Documents.Report.Report report = new Infragistics.Documents.Report.Report(); ultraGridDocumentExporter1.AutoSize = Infragistics.Win.UltraWinGrid.DocumentExport.AutoSize.SizeColumnsAndRowsToContent; ISection section = report.AddSection(); section.PageMargins.Left = 30; section.PageMargins.Top = 20; section.PageMargins.Bottom = 20; section.PageMargins.Right = 30; ISectionHeader _header = section.AddHeader(); _header.Height = 80; IText rptHeader = _header.AddText(0, 0); Style textStyle = new Style(new Infragistics.Documents.Graphics.Font("Tahoma", 18), Infragistics.Documents.Graphics.Brushes.Black); rptHeader.Alignment = TextAlignment.Center; StringBuilder headerText = new StringBuilder(); headerText.Append("left text"); headerText.Append("center text"); headerText.Append("right text"); rptHeader.AddContent(headerText.ToString(), textStyle); ISectionFooter _footer = section.AddFooter(); _footer.Height = 80; IText rptFooter = _footer.AddText(0, 0); StringBuilder footerText = new StringBuilder(); footerText.Append("footer left text "); footerText.Append("center text "); footerText.Append("right text); rptFooter.Alignment = TextAlignment.Center; rptFooter.AddContent(footerText.ToString(), textStyle);
ultraGridDocumentExporter1.Export(ultraWinGrid1, section); report.Publish(@"C:\test.pdf", Infragistics.Documents.Report.FileFormat.PDF);
Help appreciated! thanks
How big a grid are we talking about here? Personally, I've exported a few thousand rows with no problems.
If you can duplicate the Out Of Memory exception in a small sample projec, you should Submit an incident to Infragistics Developer Support so they can check it out. There are, of course, some reasonable limits to the amount of memory any particular machine can handle, but we can certainly take a look and make sure this is not a bug.
Ok. Thanks Mike.
PDF format works differently than printing. You cannot span a grid across multiple pages horizontally when exporting to PDF. Adobe Acrobat reader does not support this sort of printing, anyway, as far as I know. So the grid will always be fit to a single page and the page size is adjusted by the exporter so that it can fit the entire grid on one page.
I don't know about the OutOfMemoryException. I suppose if your grid is really huge, it's possible you could run out of memory on the machine.