๐Ÿ“Š Accessible Tables

Full table structure with THead/TBody, header scope, ID/Headers associations, and captions.

C# โ€” Accessible Table
var table = root.AddChild(StructureType.Table);

// Caption linked to the table
var caption = table.AddCaption();
page.AddTaggedText(caption,
    "Table 1: Employees", 72, 710);

// Header row group
var thead = table.AddTableHead();
var hrow = thead.AddTableRow();

// Header cells with scope and ID
var thName = hrow.AddHeaderCell(
    PdfTableScope.Column, id: "name",
    shortText: "Name");
var thDept = hrow.AddHeaderCell(
    PdfTableScope.Column, id: "dept",
    shortText: "Dept");
var thEmail = hrow.AddHeaderCell(
    PdfTableScope.Column, id: "email",
    shortText: "Email");

// Body row group
var tbody = table.AddTableBody();
var row1 = tbody.AddTableRow();

// Data cells reference header IDs
var td1Name = row1.AddDataCell("name");
var td1Dept = row1.AddDataCell("dept");
var td1Email = row1.AddDataCell("email");

// Render header cells
page.AddTaggedText(thName, "Name", 72, 680);
page.AddTaggedText(thDept, "Dept", 220, 680);
page.AddTaggedText(thEmail, "Email", 360, 680);

// Render data cells
page.AddTaggedText(td1Name, "Alice", 72, 655);
page.AddTaggedText(td1Dept, "Eng", 220, 655);
page.AddTaggedText(td1Email,
    "alice@example.com", 360, 655);
Screenshot of the Accessible Table PDF showing an Employee Directory heading, a table caption, a blue header row with Name, Department, and Email columns, and three data rows with alternating gray backgrounds โ€” all properly tagged with THead, TBody, TH with scope=Column, and TD with headers references

You should see a bold "Accessible Table" heading, a "Table 1: Employees" caption, a header row with columns Name / Dept / Email, and one data row containing Alice / Eng / alice@example.com. In a PDF viewer's Tags panel the structure should show Table โ€บ Caption, THead โ€บ TR โ€บ TH (ร—3), TBody โ€บ TR โ€บ TD (ร—3).
File: 06_accessible_table.pdf

โ™ฟ Why Table Structure Matters

Screen readers use header scope and ID/Headers associations to announce "Name: Alice, Department: Engineering" as users navigate cells. Without this structure, a screen reader would just say "Alice" with no context about which column it belongs to.

Table Structure Elements

MethodCreatesPurpose
AddTableHead()THeadHeader row group
AddTableBody()TBodyBody row group
AddTableFoot()TFootFooter row group
AddTableRow()TRTable row
AddHeaderCell(scope, id)THHeader cell with scope
AddDataCell(headerIds)TDData cell linked to headers
AddCaption()CaptionTable caption/title