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
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.
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 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?
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.
I have tested the above. But its only appear in the first page. I need this on all the page. Please help me on this.
What you need to do is add a Header to the section and then set Repeat to true:
ISectionHeader header = section.AddHeader();header.Repeat = true;
Thank you.
I have done.