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
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.
Ok. Thanks Mike.
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.
Using the code below to export to a PDF file I am losing columns and the final column on the page does not fit so it is being cut in half. Currently running INF 10.3
Infragistics.Documents.Report.Report pdfReport = new Infragistics.Documents.Report.Report();#region . Add Header .ISection section = pdfReport.AddSection();IText sectionHeader = section.AddText();sectionHeader.AddContent(string.Format("Order Inquire"));sectionHeader.AddLineBreak();sectionHeader.AddContent(string.Format("Some text"));sectionHeader.AddLineBreak();sectionHeader.AddContent(string.Format("Printed: " + DateTime.Now.ToString()));sectionHeader.AddLineBreak();sectionHeader.AddLineBreak();sectionHeader.Alignment = Infragistics.Documents.Report.TextAlignment.Center;this.ultraGridDocumentExporter.Export(this.ultraGrid1, section);Infragistics.Documents.Report.IGap sectionGap = section.AddGap();sectionGap.Height = new Infragistics.Documents.Report.FixedHeight((float)25);this.ultraGridDocumentExporter.Export(this.posPaymentGrid, section);#endregionpdfReport.Publish(saveFileDialogPDF.FileName, Infragistics.Documents.Report.FileFormat.PDF);
However if I do not add the section and simply do the code below. All the columns print and are resized to fit.
this.ultraGridDocumentExporter.Export(this.ultraGrid1, saveFileDialogPDF.FileName);
Am I adding the section correctly or is the section causing the grid not to be resized?
Hi Michael,
I have attached my sample here which uses your code. See if you get the same problem when you run my sample. If so, then this must be a problem with the version of the controls you are using.
If not, then the problem must be something else in your application like a property or event handler in your code that is not in the sample.
I could not run this against the old version of Infragistics 10.3. I upgraded the solution to 11.1 and it worked correctly. There must be something different with my grid. I will do some more research. Thanks.