I currently have a nice report that I can print whose code looks like
ultraGridPrintDocument1 = new Infragistics.Win.UltraWinGrid.UltraGridPrintDocument(); ultraGridPrintDocument1.Grid = ultraGrid1;ultraGridPrintDocument1.Header.TextCenter = "Some Header";ultraGridPrintDocument1.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Legal", 850, 1400);ultraGridPrintDocument1.DefaultPageSettings.Landscape = true;ultraGridPrintDocument1.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(50, 50, 50, 50);ultraGridPrintDocument1.FitWidthToPages = 1;ultraGridPrintDocument1.Print();
(also in the initialize print for the grid I have this one line)
e.DefaultLogicalPageLayoutInfo.PageHeader = "Page: <#> of <##> Trade Date: " + TradeDate.ToShortDateString() + " Printed: " + DateTime.Now + " By: " + System.Environment.UserName;
I'm trying to replicate this exact print out in PDF format and am having a few problems. First the grid is covering the headers. Second the header isnt displaying a page number. And third the font size isnt changing.
Infragistics.Documents.Report.Text.Style headerStyle = new Infragistics.Documents.Report.Text.Style(new Infragistics.Documents.Graphics.Font("Arial", 8), Infragistics.Documents.Graphics.Brushes.Black);
Infragistics.Documents.Report.Report report = new Infragistics.Documents.Report.Report();Infragistics.Documents.Report.Section.ISection section = report.AddSection();Infragistics.Documents.Report.Section.ISectionHeader header = section.AddHeader(); section.PageOrientation = Infragistics.Documents.Report.PageOrientation.Landscape;section.PageSize = Infragistics.Documents.Report.PageSizes.A4;Infragistics.Documents.Report.Text.IText text = header.AddText(0,0);Infragistics.Documents.Report.Text.IText text2 = header.AddText(0, 10);text.Alignment.Horizontal = Infragistics.Documents.Report.Alignment.Center;
text.AddContent("Some Header");text.Style = headerStyle;
text2.Alignment.Horizontal = Infragistics.Documents.Report.Alignment.Left;text2.AddContent("Page: <#> of <##> " + System.Environment.UserName);
text2.Style = headerStyle;
ultraGridDocumentExporter1.Export(ultraGrid1, section);
Exporting the grid to a PDF document assumes that the grid will be in it's own section. The grid already uses the Header area, so anything you put in the Header of the section probably won't work well with the the UltraGridDocumentExporter, since it won't know about it.
If you want the PDF to look exactly like the printed grid, then have you considered getting a PDF print driver so you can simply print to PDF format?
Using a PDF printer isnt really an option for me. Is it possible to have multiple sections on the same page and have part of the section roll over to the next page if its too long. And how come my font size isnt changing.
The sample I was referring to is the WinGrid Samples Explorer. All of the samples install with the NetAdvantage SDK, which is a separate installer from the actual controls.
It's usually in a path something like this:
\2009.2\Samples\WinGrid\CS\SamplesExplorer
The sample is called "V7.2 Document Export" and it uses the BeginExport event of the UltraGridDocumentExporter to add in some text before the grid. I'm honestly not sure how this will work with headers, though.
I'm sorry you never said it wouldn't work, you just said it probably won't work well. And none of the examples I saw with exporting documents used the UltraGridDocumentExporter so they didnt help much in figuring it out.
tonydt1g3r said:so its not possible to display a grid and text together?
Just to clarify, I didn't say that. You can certainly add text before or after the grid in the same section or in a different section. In fact, the sample in the WinGrid Samples Explorer does this.
I figured out the problem.... it is possible to use headers with the section along with a grid. You just cant rely on the default header size, if you set it manually the grid will appear below it.
so its not possible to display a grid and text together?
Is it possible to set the text property of the grid and have that print & save to a pdf. in my initial test it seems like only the data of the grid is being printed and saved.