PdfTable Class |
Namespace: Atalasoft.PdfDoc.Generating.Shapes
The PdfTable type exposes the following members.
Name | Description | |
---|---|---|
ActualHeight |
returns the height of the filled table.
| |
BorderColor |
Gets/sets the color to draw the border grid lines.
The default border color is black.
| |
BorderStyle |
The border style for the table. See PdfTableBorderStyle
The default border style is None.
Border options are: Grid,Vertical,Horizontal,Outline, None.
| |
BorderWidth |
Gets/sets the width the border should be drawn. This applies to all the lines that are drawn for the table
The default border width is 1.
| |
Bounds |
Gets/sets the bounds for the table
| |
Columns |
Returns the columns already set for the PdfTable. See PdfTableColumn | |
FilledRowsCount |
Gets a count of rows placed to the table after the Fill() method using.
This value takes into account header row if it exists.
| |
FontName |
Gets/sets the name of the font to be used
| |
FontSize |
Gets/sets the size of the font.
| |
HasMoreRows |
Returns true if there are more rows to draw for the table.
Check this after the Fill() method to see if all the rows were written to the table.
| |
HeaderFontName |
Gets or sets the name of the header font. If set to null, when Fill(PdfFontManager) is called, PdfTable will
attempt to find a font named FontName + " Bold" in the system (creating a font resource if needed),
otherwise it will use a font named by HeaderFontName.
| |
LineHeight |
Gets/sets the height of each row in the table.
If text has multiple lines the row height will be multiplied by the number of lines.
The default row height is calculated based on the font type and font size specified.
| |
Name |
Gets/sets the name of the IPdfRenderable object.
| |
ShowColumnHeadingRow |
Get/sets whether to draw the a heading row for the table. Default is true.
| |
TextPaddingLeft |
The padding from the left margin to the start of the text. This will apply to the entire table.
If there is a column TextPaddingLeft defined it will override this value.
| |
TextPaddingRight |
The padding from the end of the text to the right margin. This will apply to the entire table
If there is a column TextPaddingRight defined it will override this value.
|
Name | Description | |
---|---|---|
AddRows |
Add row data to the table. Pass an enumerator for a collection of items. Can also be an enumerator of a List<Dictionary<string,string>> object.
| |
Clone |
Copy the PdfTable object to a new instance.
Reuses the Font Resource manager. Reuses the Ta
Does not copy table rows.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Fill |
Fills the specified table with rows using the PdfTableInput enumerator
This method must be called before the table attempts to render. This fills the table with the rows provided,
it will stop at the point the table bounds height has been reached.
| |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
Render |
Generates the PDFTable. Draws each row in the table
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
// constructor takes the PdfBounds for the table, the default font type, and font size PdfTable productTable = new PdfTable(new PdfBounds(10, 100, 500, 600), "Arial", 6); // create the table columns // the columns are shown in the order they are added to the table // add a column, pass the key, display Text, and column Width productTable.Columns.Add(new PdfTableColumn("SKU", "Product Code", 50)); // if the width is not specified, the width will be calculated by using the average of what width is left productTable.Columns.Add(new PdfTableColumn("Name", "Product Name")); productTable.Columns.Add(new PdfTableColumn("Quantity", "Quantity", 25)); productTable.Columns.Add(new PdfTableColumn("UnitPrice", "Price", 50)); // specify the BorderStyle,BorderWidth, and BorderColor // BorderStyle options: Grid, Vertical, Horizontal, Outline, None productTable.BorderStyle = PdfTableBorderStyle.Vertical; productTable.BorderWidth = .5; productTable.BorderColor = PdfColorFactory.FromColor(System.Drawing.Color.Black); List<Product> productList = CreateProductList(); productTable.AddRows(productList.GetEnumerator()); // create the Pdf doc and page to draw to PdfGeneratedDocument pdfDoc = new PdfGeneratedDocument(); PdfGeneratedPage page = PdfDefaultPages.Letter; // populate the table with the data collection productTable.Fill(pdfDoc.Resources.Fonts); // add the table to the page page.DrawingList.Add(productTable); pdfDoc.Pages.Add(page);
PdfGeneratedDocument pdfDoc = new PdfGeneratedDocument(); PdfGeneratedPage page = PdfDefaultPages.Letter; List<Product> productList = CreateProductList(30); PdfTable productTable = new PdfTable(new PdfBounds(10, 100, 500, 200), "Arial", 6); productTable.Columns.Add(new PdfTableColumn("SKU", "Product Code", 30)); productTable.Columns.Add(new PdfTableColumn("Name", "Product Name")); productTable.Columns.Add(new PdfTableColumn("Quantity", "Quantity", 50)); productTable.Columns.Add(new PdfTableColumn("UnitPrice", "Price", 50)); productTable.BorderStyle = PdfTableBorderStyle.Grid; productTable.BorderWidth = .5; productTable.BorderColor = PdfColorFactory.FromColor(System.Drawing.Color.Black); productTable.AddRows(productList.GetEnumerator()); // populate the table with the collection data productTable.Fill(pdfDoc.Resources.Fonts); // add the table to the page page.DrawingList.Add(productTable); pdfDoc.Pages.Add(page); while (productTable.HasMoreRows) { page = PdfDefaultPages.Letter; productTable = (PdfTable)productTable.Clone(); // populate the table with the collection data productTable.Fill(pdfDoc.Resources.Fonts); // add the table to the page page.DrawingList.Add(productTable); pdfDoc.Pages.Add(page); } using (FileStream fs = new FileStream("MultipleIterationExampleTest.pdf", FileMode.Create, FileAccess.ReadWrite, FileShare.Read)) pdfDoc.Save(fs);