The sample shows instructions and algorithm of how to create tables in pdf with pdf sdk and how to make it run in your C# application. Want to create tables in pdf with pdf sdk in your C# app? ByteScout PDF Suite is designed for it. ByteScout PDF Suite is the set that includes 6 SDK products to work with PDF from generating rich PDF reports to extracting data from PDF documents and converting them to HTML. This bundle includes PDF (Generator) SDK, PDF Renderer SDK, PDF Extractor SDK, PDF to HTML SDK, PDF Viewer SDK and PDF Generator SDK for Javascript.
These C# code samples for C# guide developers to speed up coding of the application when using ByteScout PDF Suite. IF you want to implement the functionality, just copy and paste this code for C# below into your code editor with your app, compile and run your application. If you want to use these C# sample examples in one or many applications then they can be used easily.
ByteScout provides the free trial version of ByteScout PDF Suite along with the documentation and source code samples.
On-demand (REST Web API) version:
Web API (on-demand version)
On-premise offline SDK for Windows:
60 Day Free Trial (on-premise)
using System; using System.Diagnostics; using Bytescout.PDF; namespace Tables { /// <summary> /// This example demonstrates how to create tables. /// </summary> class Program { static void Main() { // Create new document Document pdfDocument = new Document(); pdfDocument.RegistrationName = "demo"; pdfDocument.RegistrationKey = "demo"; // Add page Page page = new Page(PaperFormat.A4); pdfDocument.Pages.Add(page); DeviceColor lightGrayColor = new ColorGray(200); DeviceColor whiteColor = new ColorGray(255); DeviceColor lightBlueColor = new ColorRGB(200, 200, 250); DeviceColor lightRedColor = new ColorRGB(255, 200, 200); // Create a table and set default background color Table table = new Table(); table.BackgroundColor = lightGrayColor; // Add row headers column and set its color table.Columns.Add(new TableColumn("RowHeaders")); table.Columns[0].BackgroundColor = lightGrayColor; // Add columns A, B, C, ... for (int c = 0; c < 10; c++) { string columnName = Convert.ToChar('A' + c).ToString(); table.Columns.Add(new TableColumn(columnName, columnName)); } // Add rows for (int r = 0; r < 10; r++) { // Create new row and set its background color TableRow row = table.NewRow(); row.BackgroundColor = whiteColor; // Set row header text row["RowHeaders"].Text = (r + 1).ToString(); // Set cell text for (int c = 0; c < 10; c++) { string columnName = Convert.ToChar('A' + c).ToString(); row[columnName].Text = columnName + (r + 1); } // Add the row to the table table.Rows.Add(row); } // Decorate the table table.Rows[1]["B"].BackgroundColor = lightRedColor; table.Columns[2].BackgroundColor = lightBlueColor; table.Rows[1].BackgroundColor = lightBlueColor; table.Rows[1]["RowHeaders"].BackgroundColor = lightBlueColor; // Draw the table on canvas page.Canvas.DrawTable(table, 20, 20); // Save document to file pdfDocument.Save("result.pdf"); // Cleanup pdfDocument.Dispose(); // Open result document in default associated application (for demo purpose) ProcessStartInfo processStartInfo = new ProcessStartInfo("result.pdf"); processStartInfo.UseShellExecute = true; Process.Start(processStartInfo); } } }
60 Day Free Trial or Visit ByteScout PDF Suite Home Page
Explore ByteScout PDF Suite Documentation
Explore Samples
Sign Up for ByteScout PDF Suite Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
60 Day Free Trial or Visit ByteScout PDF Suite Home Page
Explore ByteScout PDF Suite Documentation
Explore Samples
Sign Up for ByteScout PDF Suite Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
also available as: