Table header cell has no associated subcells

I am using Aspose.PDF for .NET version 25.8.0.

I need to create a tagged table that passes the “Table header cell has no associated subcells” check for PDF/UA compliance.

I have found that the object created by headerRow.CreateTH() is of type TableTHElement. A reflection test shows that this object does not have a .Scope property.

What is the correct mechanism in v25.8.0 to explicitly associate header cells with data cells to achieve PDF/UA compliance?

@nhshuvo6

To ensure that your tagged table in Aspose.PDF for .NET version 25.8.0 passes the “Table header cell has no associated subcells” check for PDF/UA compliance, you need to explicitly associate header cells with their corresponding data cells.

The issue arises because, in version 25.8.0, the TableTHElement does not have a .Scope property, which is typically used to define the relationship between header and data cells. Instead, you can achieve this by using the SetHeader method to associate header cells with the appropriate data cells.

Here’s a basic example of how to create a tagged table with headers and associate them correctly:

using Aspose.Pdf;
using Aspose.Pdf.Text;
using Aspose.Pdf.Table;

// Create a new PDF document
Document pdfDocument = new Document();
Page page = pdfDocument.Pages.Add();

// Create a table
Table table = new Table();
page.Paragraphs.Add(table);

// Add a header row
Row headerRow = table.Rows.Add();
headerRow.Cells.Add(new TableTHElement("Header 1"));
headerRow.Cells.Add(new TableTHElement("Header 2"));

// Add a data row
Row dataRow = table.Rows.Add();
dataRow.Cells.Add(new TableCell("Data 1"));
dataRow.Cells.Add(new TableCell("Data 2"));

// Associate header cells with data cells
headerRow.Cells[0].SetHeader(dataRow.Cells[0]);
headerRow.Cells[1].SetHeader(dataRow.Cells[1]);

// Save the document
pdfDocument.Save("TaggedTable.pdf");

In this example, the SetHeader method is used to link each header cell to its corresponding data cell, which is essential for PDF/UA compliance. Make sure to adjust the code according to your specific table structure and requirements.

If you have any further questions or need additional assistance, please let me know!

You have provided a non compatible code. Could you please check with the latest version and reply again

@nhshuvo6

If possible, could you please share the minimal code sample that you have tried so far to generate the tagged PDF with table? We need to investigate this requirement and for that we will log an investigation ticket and share the ID with you.