Hi all,in my UltraGrid I have an ultraGridDocumentExporter to export the Grid content in a PDF file. Is it possible to export in a predefinited pdf template (that has, for example, header and footer).
Thanks a lot.
Luigi
At the moment, my BeginExport method is this one:
private void ultraGridDocumentExporter1_BeginExport(object sender, BeginExportEventArgs e) { foreach (UltraGridBand band in e.Layout.Bands) { switch (band.Index) { case 1: band.Hidden = true; break; default: band.Indentation = 0; break; } } }
How can I modify it?
Right now you are using the overload of the Export method that takes a file name. That's fine, you can do it that way, also.
What you would do is handle the BeginExport event of the UltraGridDocumentExporter. The event passes you an ISection. You can use the AddText method to add an IText object to the ISection and then use AddContent to add some content to the IText. This all happens before the grid is exported, so your text will appear before the grid.
Hi Mike,at the moment,my Pdf export is like this one:
private void pDFToolStripMenuItem_Click(object sender, EventArgs e){ var nameFilePdf = String.Empty;
try { saveFileDialog1.Filter = "(*.pdf)|*.pdf|All files (*.*)|*.*"; saveFileDialog1.AddExtension = true; saveFileDialog1.DefaultExt = ".pdf"; saveFileDialog1.ShowDialog(); nameFilePdf = saveFileDialog1.FileName + ".pdf";
if (saveFileDialog1.FileName != "") { ultraGridDocumentExporter1.Export(MyUltraGrid, nameFilePdf, GridExportFileFormat.PDF); }
// catch section....
and I need only to put a simple header - for example the Company name - in the Pdf created.
Could you help me?
You mean this code Mike?
// Header Infragistics.Documents.Report.Grid.IGridHeader header = grid.Header; header.Height = new Infragistics.Documents.Report.FixedHeight(35); header.Repeat = true;
Infragistics.Documents.Report.Grid.IGridCell cell = header.AddCell(); cell.ColSpan = 5; cell.Alignment.Vertical = Infragistics.Documents.Report.Alignment.Middle; cell.Borders = new Infragistics.Documents.Report.Borders(Infragistics.Documents.Graphics.Pens.Black); cell.Background = new Infragistics.Documents.Report.Background(new Infragistics.Documents.Graphics.Color(220, 240, 240));
text = cell.AddText(); text.Style = normalStyle; text.Alignment = Infragistics.Documents.Report.TextAlignment.Center; text.AddContent("Grid Header");
// Footer Infragistics.Documents.Report.Grid.IGridFooter footer = grid.Footer; footer.Height = new Infragistics.Documents.Report.FixedHeight(35); footer.Repeat = true;
cell = footer.AddCell(); cell.ColSpan = 5; cell.Alignment.Vertical = Infragistics.Documents.Report.Alignment.Middle; cell.Borders = new Infragistics.Documents.Report.Borders(Infragistics.Documents.Graphics.Pens.Black); cell.Background = new Infragistics.Documents.Report.Background(new Infragistics.Documents.Graphics.Color(220, 220, 240));
text = cell.AddText(); text.Style = normalStyle; text.Alignment = Infragistics.Documents.Report.TextAlignment.Center; text.AddContent("Grid Footer");
Hi Luigi,
Not sure what you mean by predefined. But you can create a report object and add a header to it or anything you want, then export the grid into it, then write a footer or some more text after the grid.
The sample for the DocumentExporter in the WinGrid samples explorer does this.