Could you point to any online example to use Infragistics.Documents for PDF ?
Thanks ..
Not..
I can not use WEB CONTROL for this.
It will not run on web application.
Our task is to create PDF document that looks as EXCEL spreadsheet from XML.
Look at code bellow [I could not figure out how to attach file on this post ?].
It has 2 test methods :
TestWithoutUltraWebGrid()
TestWithUltraWebGrid()
We can not use TestWithUltraWebGrid()
Because our XML has nested structure [I think that it is limitation on web grid]
Ex
<A>
</A>
<\A>
Do you have any example similar what I am doing in that code ?
class PdfCreator {
public byte[] TestWithoutUltraWebGrid() { //creates the report Report r = new Report(); //creates the section ISection sect1 = r.AddSection(); //creates a non repeating header ISectionHeader sect1Head = sect1.AddHeader(); sect1Head.Repeat = false; sect1Head.Height = 80; //------------------------------------------------------------------- //styles used in the header Infragistics.Documents.Report.Text.Style headerstyle = new Infragistics.Documents.Report.Text.Style(new Font("Old English Text MT", 32), Brushes.Black); Infragistics.Documents.Report.Text.Style headerSmall = new Infragistics.Documents.Report.Text.Style(new Font("Arial", 8), Brushes.Black); Infragistics.Documents.Report.Text.Style headerTiny = new Infragistics.Documents.Report.Text.Style(new Font("Arial", 6), Brushes.Black);
//adds a group to the header to help layout contents IGroup sect1HeadGroup = sect1Head.AddGroup(0, 0); //using grid to layout first set of elements IGrid gridObject = sect1HeadGroup.AddGrid(); //------------------------------------------------------------------- //sets some layout properties on the object gridObject.Borders.Corners.All = new Infragistics.Documents.Report.Corner( Infragistics.Documents.Graphics.Pens.DodgerBlue, Infragistics.Documents.Utils.Converter.PixelsToPoints(10));
gridObject.Borders.All = new Infragistics.Documents.Report.Border( Infragistics.Documents.Graphics.Pens.DodgerBlue);
gridObject.Margins.All = Infragistics.Documents.Utils.Converter.PixelsToPoints(10);
gridObject.Paddings.All = Infragistics.Documents.Utils.Converter.PixelsToPoints(10); //------------------------------------------------------------------- //using the gridpattern to style the grid GridPattern gridPattern = new GridPattern(); gridPattern.Margins = new Margins(5); gridPattern.Paddings = new Paddings(10); gridObject.ApplyPattern(gridPattern);
//adds 5 columns, columns must be added for a grid element gridObject.AddColumn(); gridObject.AddColumn(); gridObject.AddColumn(); gridObject.AddColumn(); gridObject.AddColumn();//5 Columns for (int II = 1; II < 50; II++) { IGridRow gridROW = gridObject.AddRow(); AddRow(ref gridROW, II); } return SaveToMemory(ref r); }
public byte[] TestWithUltraWebGrid() { Infragistics.Documents.Report.Report report = new Infragistics.Documents.Report.Report(); Infragistics.Documents.Report.Section.ISection section1 = report.AddSection(); section1.PageMargins = new Infragistics.Documents.Report.Margins(50);
Infragistics.WebUI.UltraWebGrid.UltraWebGrid uwgrid = new Infragistics.WebUI.UltraWebGrid.UltraWebGrid();
System.Data.DataSet dsWebGrid = new System.Data.DataSet("WebGrid"); string xmlurl = @"C:\Tasks\Web-Managers\Test\ExcelTest_WebDocumentExporter\TIF\GridData2.xml"; dsWebGrid.ReadXml(xmlurl); uwgrid.DataSource = dsWebGrid; uwgrid.DataBind();
Infragistics.WebUI.UltraWebGrid.DocumentExport.UltraWebGridDocumentExporter ex = new UltraWebGridDocumentExporter(); ex.Export(uwgrid, section1);
return SaveToMemory(ref report); }
private void AddRow(ref IGridRow gridROW, int rowCt) { IGridCell gridCELL = null; IText cellTEXT = null;
gridCELL = gridROW.AddCell(); cellTEXT = gridCELL.AddText(); cellTEXT.AddContent("Row [" + rowCt + "]Coll[1]"); gridCELL.Borders = new Borders(new Pen(Colors.Black, DashStyle.Solid), 2);
gridCELL = gridROW.AddCell(); cellTEXT = gridCELL.AddText(); cellTEXT.AddContent("Row [" + rowCt + "]Coll[2]"); gridCELL.Borders = new Borders(new Pen(Colors.Black, DashStyle.Solid), 2);
gridCELL = gridROW.AddCell(); cellTEXT = gridCELL.AddText(); cellTEXT.AddContent("Row [" + rowCt + "]Coll[3]"); gridCELL.Borders = new Borders(new Pen(Colors.Black, DashStyle.Solid), 2);
gridCELL = gridROW.AddCell(); cellTEXT = gridCELL.AddText(); cellTEXT.AddContent("Row [" + rowCt + "]Coll[4]"); gridCELL.Borders = new Borders(new Pen(Colors.Black, DashStyle.Solid), 2);
gridCELL = gridROW.AddCell(); cellTEXT = gridCELL.AddText(); cellTEXT.AddContent("Row [" + rowCt + "]Coll[5]"); gridCELL.Borders = new Borders(new Pen(Colors.Black, DashStyle.Solid), 2);
}
private byte[] SaveToMemory(ref Report PDFReport) { byte[] bytesExcel = null; try { using (System.IO.MemoryStream theStream = new System.IO.MemoryStream()) { PDFReport.Publish(theStream, FileFormat.PDF); bytesExcel = (byte[])Array.CreateInstance(typeof(byte), theStream.Length); theStream.Position = 0; theStream.Read(bytesExcel, 0, (int)theStream.Length); theStream.Close(); } } catch (Exception e) { throw new Exception("Failed to convert to Excel workbook to stream.\n" + e.Message); } return bytesExcel; }
Hi dmcmichael,
The following sample illustrates how a custom PDF/XPS report may be generated:
http://samples.infragistics.com/aspnet/Samples/Infragistics.Documents/Display/Export%20to%20PDF%20or%20XPS/Default.aspx?cn=infragistics-documents&sid=1ee1141c-b6aa-4904-9aa8-dcb724811069
You may also find useful information regarding writing reports in our documentation at:
http://help.infragistics.com/NetAdvantage/ASPNET/2011.2/CLR4.0/?page=DocumentEngine_Writing_Reports.html
Please let me know if this helps.
Best Regards,
Petar IvanovDeveloper Support EngineerInfragistics, Inc.http://es.infragistics.com/support
Thanks on quick answer but it is not what I need ..
I can not use [WebDataGrid] exporter.Is any example to create pdf from "raw data" not data from "grid" ..
I need to create PDF using Infragistics35.WebUI.Documents.v9.1Our input format is custom xml and we have to create PDF on similar way that we create EXCEL with Infragistics35.WebUI.Excel.v9.1 ..
Hello,
The following are online samples for using the PDF feature:
http://samples.infragistics.com/aspnet/Samples/WebDataGrid/Data/Document-Exporter/Default.aspx?cn=document-exporter&sid=956dc5cd-b842-4cd9-8e92-940fdd3425b2.
http://samples.infragistics.com/reporting/RunSamples.aspx?cn=print-and-export#/print-and-export/export-a-report.
In the 'Windows Form Feature Browser' if you have marked 'Samples' before installing the WinFroms controls, there is a sample called 'Samples Gallery' under the Publishing and Printing' tab.
Please feel free to let me know if I misunderstood you or if you have any other questions.