How to create a Table in a PDF

1 Answer 5 Views
Table
Terry
Top achievements
Rank 2
Terry asked on 13 Jan 2026, 01:05 PM

I have a C#, WPF application that generates some data. I need to put that data into various Tables in a PDF file.

I'm trying to create a Table in a PDF by following this example.

I don't know if the Table is:

Telerik,Reporting.Table
or
Telerik.Reporting.Processing.Table.

Either way, I cannot get it to work.

If I use:

Telerik.Reporting.Table table = new();

the table does not have ".Rows."

If I use:

Telerik.Reporting.Processing.Table table = new();

I get the following error:

'Table' does not contain a constructor that takes 0 arguments.

Please help, I have not been able to find a way to get this to work.

Thanks,
Terry

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 14 Jan 2026, 11:40 AM

Hi, Terry,

According to the provided information, it seems that your question is more related to Telerik Document Processing Libraries than to Telerik Reporting. Please correct me if I am wrong.

RadPdfProcessing provides convenient API for generating tables with the desired cells content. Learn how to get started with the library.

I would recommend you to have a look at the following KB articles which demonstrate a sample approach how to generate a PDF table form custom data. They require installing the Telerik.Windows.Documents.Fixed NuGet package: 

Generating a Table with RadFixedDocumentEditor

Generating a PDF Product Catalog

As to the Telerik Reporting product, it is also possible to generate a report with a Table that is bound to a collection of business objects and export the report to PDF format. A sample approach is demonstrated in the following article:

How to Create Tables Programmatically in Telerik Reporting

However, I have prepared a sample code snippet for your reference to simulate the product catalog sample using Telerik Reporting:

using System.Diagnostics;
using System.IO;
using Telerik.Reporting;
using Telerik.Reporting.Drawing;
using Telerik.Reporting.Processing;

namespace _1707715GeneratePDFtableFromList
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var items = CreateSampleItems();

            string outputFilePath = "ProductCatalog.pdf";
            File.Delete(outputFilePath);
            GenerateItemsReportPdf(outputFilePath, items);

            Process.Start(new ProcessStartInfo() { FileName = outputFilePath, UseShellExecute = true });

        }
        public static void GenerateItemsReportPdf(string outputPdfPath, IList<Item> items)
        {
            // 1) Create a report
            var report = new Telerik.Reporting.Report
            {
                Name = "ItemsReport",
                PageSettings = new PageSettings
                {
                    PaperKind = System.Drawing.Printing.PaperKind.A4,
                    Margins = new MarginsU(Unit.Mm(15), Unit.Mm(15), Unit.Mm(15), Unit.Mm(15)),
                }
            };

            // 2) Add a detail section that will host the table
            var detail = new Telerik.Reporting.DetailSection { Height = Unit.Inch(1.0) };
            report.Items.Add(detail);

            // 3) Build a Table with 3 columns: Image | Description | Price
            var table = new Telerik.Reporting.Table
            {
                Location = new PointU(Unit.Mm(0), Unit.Mm(0)),
                Size = new SizeU(Unit.Mm(170), Unit.Mm(10)), // width will adapt; height grows with rows
            };
            
            // Layout: fixed body columns (Image ~30mm, Description ~110mm, Price ~30mm)
            table.Body.Columns.Add(new TableBodyColumn(Unit.Mm(30)));
            table.Body.Columns.Add(new TableBodyColumn(Unit.Mm(110)));
            table.Body.Columns.Add(new TableBodyColumn(Unit.Mm(30)));

            // One body row for the detail record
            table.Body.Rows.Add(new TableBodyRow(Unit.Mm(12)));

            // Row group (required for a detail table)
            var detailGroup = new TableGroup();
            table.RowGroups.Add(detailGroup);


            var colImg = new TableGroup { ReportItem = HeaderCell("Image",8) };
            var colDesc = new TableGroup { ReportItem = HeaderCell("Description",8) };
            var colPrice = new TableGroup { ReportItem = HeaderCell("Price",8) };

            table.ColumnGroups.Add(colImg);
            table.ColumnGroups.Add(colDesc);
            table.ColumnGroups.Add(colPrice);

            //table.ColumnHeadersPrintOnEveryPage = true;

            // 4) Cells: PictureBox | Description TextBox | Price TextBox
            // PictureBox (bind to Fields.Image). It can be a file path, absolute URI, or Base64/SVG string. 
            var pictureBox = new Telerik.Reporting.PictureBox
            {

                Value = "=Fields.Image", // supports local/absolute path or URL; see notes below.
                Size = new SizeU(Unit.Mm(25), Unit.Mm(25)),
                Sizing = ImageSizeMode.ScaleProportional,
            };

            // Description
            var descBox = new Telerik.Reporting.TextBox
            {

                Value = "=Fields.Description",
                Size = new SizeU(Unit.Mm(110), Unit.Mm(6)),
            };

            // Price formatted as currency
            var priceBox = new Telerik.Reporting.TextBox
            {

                Value = "=Fields.Price",
                Format = "{0:C2}", // or set Culture explicitly if needed
                Size = new SizeU(Unit.Mm(25), Unit.Mm(6)),

            };

            // Put controls into the table body cells
            table.Body.SetCellContent(0, 0, pictureBox);
            table.Body.SetCellContent(0, 1, descBox);
            table.Body.SetCellContent(0, 2, priceBox);

            // Zebra striping via conditional formatting (optional)
            var altFormat = new FormattingRule();
            altFormat.Filters.Add(new Filter("=RowNumber()", FilterOperator.NotEqual, "0")); // rule per row
            altFormat.Style.BackgroundColor = System.Drawing.Color.FromArgb(250, 250, 250);
            table.ConditionalFormatting.Add(altFormat);

            // Borders for the whole table (optional)
            table.Style.BorderStyle.Default = BorderType.Solid;
            table.Style.BorderColor.Default = System.Drawing.Color.Gainsboro;

            // 5) Bind the Table to the data source. 


            var ods = new ObjectDataSource { DataSource = items };
            report.DataSource = ods;
            table.Bindings.Add(new Binding("DataSource", "=ReportItem.DataObject")); // reuses parent data 
            detail.Items.Add(table);

            // 7) Render to PDF via ReportProcessor.
            var reportProcessor = new ReportProcessor();
            var instanceSource = new InstanceReportSource { ReportDocument = report };
            var result = reportProcessor.RenderReport("PDF", instanceSource, null);

            File.WriteAllBytes(outputPdfPath, result.DocumentBytes);
        }


        static Telerik.Reporting.ReportItem HeaderCell(string title, double headerHeightMm)
        {
            var headerText = new Telerik.Reporting.TextBox
            {
                Value = title,
                Size = new SizeU(Unit.Mm(20), Unit.Mm(headerHeightMm)), // width here is ignored; column width rules
                Style =
            {
                BackgroundColor = System.Drawing.Color.FromArgb(243, 246, 249), 
                TextAlign = HorizontalAlign.Left
            }
            };
            var panel = new Telerik.Reporting.Panel
            {
                Size = new SizeU(Unit.Mm(30), Unit.Mm(8)) // header row height
            };
            panel.Items.Add(headerText);
            return panel;
        }


        private static List<Item> CreateSampleItems()
        {
            return new List<Item>
        {
            new Item
            {
                Image = "product-image-1.png",
                Description = "Premium Wireless Headphones with noise cancellation technology",
                Price = 199.99m
            },
            new Item
            {
                Image = "product-image-2.png",
                Description = "Smartphone with 128GB storage and dual camera system",
                Price = 699.99m
            },
            new Item
            {
                Image = "product-image-4.png",
                Description = "Laptop with 16GB RAM and 512GB SSD for professional use",
                Price = 1299.99m
            }
        };
        }
        public class Item
        {
            public string Image { get; set; }
            public string Description { get; set; }
            public decimal Price { get; set; }
        }
    }
}

 

Feel free to use this Telerik product that fits your requirements best.

I hope you find this information helpful. Please, let me know if there is anything else I can assist you with.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Table
Asked by
Terry
Top achievements
Rank 2
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or