Automating PDF/UA Accessibility with AI: Describing DOCX Documents Using TX Text Control and LLMs
This article shows how to use TX Text Control together with the OpenAI API to automatically add descriptive texts (alt text and labels) to images, links, and tables in a DOCX. The resulting document is then exported as a PDF/UA compliant PDF document.

Accessible documents are no longer optional. Banks send statements to millions of customers daily. Insurers deliver policies and claims letters daily. Governments publish forms and notices on a large scale. If these PDFs are not accessible, people who rely on assistive technologies are excluded, and organizations face legal risks.
Preview
This article describes an upcoming feature of TX Text Control 34.0, planned for release in November 2025. The code examples use the OpenAI API; however, you can use other large language models (LLMs) with similar functionality.
This article demonstrates how to use TX Text Control with the OpenAI API to automatically add alt text and labels to images, links, and tables in a DOCX file. Then, it shows how to export the file to PDF/A, positioning your pipeline for full PDF/UA compliance.
Why this Topic Matters
Creating accessible documents is complex and time-consuming. It requires an in-depth knowledge of accessibility standards, such as PDF/UA, as well as the ability to implement these standards in the creation of documents. Many organizations struggle to meet these requirements due to a lack of expertise or resources. Adding descriptive text to elements such as tables or images is also very time-consuming.
- Inclusion: Descriptive texts allow screen readers to explain the purpose of visual and interactive elements.
- Compliance: PDF/UA is referenced in accessibility laws and procurement rules. Failing accessibility checks can result in lost deals and complaints.
- Scale: Manually writing alt text for thousands of documents is not feasible. A pragmatic and cost-effective approach is to use an automated baseline with human spot-checks.
What is PDF/UA
PDF/UA (ISO 14289) is the international standard for creating accessible PDF documents. The standard defines how to create PDF files usable by people with disabilities, including those who rely on assistive technologies, such as screen readers, magnifiers, and alternative input devices.
- Tagged structure and logical reading order
- Alternative text for non-text content (images, graphics, form fields)
- Meaningful labels for links and controls
- Language metadata and consistent semantics
Why Bring AI into the Loop?
Large language models (LLMs), such as OpenAI's GPT-4, can understand and generate human-like text based on context. These models can analyze the content of a document and generate meaningful descriptions of images, tables, and links. This capability can significantly reduce the time and effort needed to make documents accessible.
The following diagram shows the workflow: First, TX Text Control loads the document. Then, elements are iterated and extracted to be sent to the LLM. Next, the returned text is added as descriptive text to those elements. Finally, the document is exported to PDF/UA using TX Text Control.
Example
Let's take a look at the following sample document, which contains various elements that require accessibility features.
In Powershell, the following command can be used to process the document:
.\tx_descriptive_text.exe ".\Sample Document.docx" "results.pdf"
The generated output will be written to the standard output stream in the console:
[IMAGE] Picture 1 -> Snow-capped mountain peak under a clear blue sky, surrounded by rugged terrain and valleys.
[LINK] Name: ; Text: https://www.textcontrol.com; Target: https://www.textcontrol.com -> Visit Text Control for document processing solutions.
[TABLE] -> The table displays monthly sales data for three products (Alpha Widget, Beta Gadget, and Gamma Pro), along with total sales for each month and an overall total for the year.
The resulting descriptive texts for the three elements in the document are as follows:
Element | Generated Descriptive Text |
---|---|
Image | Snow-capped mountain peak under a clear blue sky, surrounded by rugged terrain and valleys. |
Table | The table displays monthly sales data for three products (Alpha Widget, Beta Gadget, and Gamma Pro), along with total sales for each month and an overall total for the year. |
Link | Visit Text Control for document processing solutions. |
This accurate representation of the document's content and structure makes it easier for users with disabilities to access the information they need.
The final PDF/UA document can be verified using Acrobat Reader:
The descriptive text will appear when you hover over the image. In order to see the table summary, you have to look at the tag more closely.
Looping Through all Elements
The following code snippet demonstrates how to loop through all the elements in a document and process the images, tables, and links within it. It uses the OpenAI API to generate a description of each element and adds the description to the element in the document.
public async Task AddDescriptiveTextAsync(string inputDocxPath, string outputPdfAPath)
{
using var tx = new ServerTextControl();
tx.Create();
tx.Load(inputDocxPath, StreamType.WordprocessingML);
// Ensure images have names
foreach (Image image in tx.Images)
{
if (string.IsNullOrWhiteSpace(image.Name))
image.Name = "image_" + Guid.NewGuid().ToString("N");
}
// Export full document to HTML and extract embedded images as data URIs
tx.Save(out string html, StringStreamType.HTMLFormat);
var images = ImageExtractor.GetImageBase64Strings(html);
// Describe images and set DescriptiveText
foreach (var imgData in images)
{
byte[] imageBytes = Convert.FromBase64String(imgData.Base64Content);
string hint = !string.IsNullOrWhiteSpace(imgData.Name)
? $"The image is named '{imgData.Name}'."
: "";
string altText = await _ai.DescribeImageAsync(imageBytes, imgData.Name, hint);
foreach (Image img in tx.Images)
{
if (img.Name == imgData.Name)
{
img.DescriptiveText = altText;
break;
}
}
// ✅ console output
Console.WriteLine($"[IMAGE] {imgData.Name ?? "(no name)"} -> {altText}");
}
// Describe hypertext links
foreach (HypertextLink link in tx.HypertextLinks)
{
string composite = $"Name: {link.Name}; Text: {link.Text}; Target: {link.Target}";
link.DescriptiveText = await _ai.DescribeFieldAsync(composite);
// ✅ console output
Console.WriteLine($"[LINK] {composite} -> {link.DescriptiveText}");
}
// Describe tables
foreach (Table table in tx.Tables)
{
table.Select();
tx.Selection.Save(out string tableHtml, StringStreamType.HTMLFormat);
table.DescriptiveText = await _ai.DescribeHtmlTableAsync(tableHtml);
// ✅ console output
Console.WriteLine($"[TABLE] -> {table.DescriptiveText}");
}
// Save as PDF/A (or PDF/UA if your pipeline ensures tagging elsewhere)
tx.Save(outputPdfAPath, StreamType.AdobePDFA);
}
The images are extracted and sent to OpenAI separately to receive a description. The table is exported as HTML using TX Text Control, and then sent to OpenAI. For links and form fields, the name, and if available, the target, are used to request a descriptive text. Take a look at the project in the GitHub repository to see the complete prompt.
Conclusion
Making documents accessible is crucial for inclusion and compliance. However, it can be complex and time-consuming. Organizations can automate the generation of descriptive texts for images, tables, and links by leveraging TX Text Control's document processing capabilities and the power of large language models like OpenAI's GPT-4, significantly reducing the effort required to create accessible documents.
This approach saves time and resources while helping to ensure that documents meet accessibility standards, such as PDF/UA.
We are excited to announce that this feature will be part of the upcoming TX Text Control 34.0 release, scheduled for November 2025. Stay tuned for more updates and detailed documentation on how to implement this functionality in your applications. We will release this sample project on GitHub.
ASP.NET
Integrate document processing into your applications to create documents such as PDFs and MS Word documents, including client-side document editing, viewing, and electronic signatures.
- Angular
- Blazor
- React
- JavaScript
- ASP.NET MVC, ASP.NET Core, and WebForms
Related Posts
Why PDF/UA and PDF/A-3a Matter: Accessibility, Archiving, and Legal Compliance
It is more important than ever to ensure that documents are accessible, archivable, and legally compliant. PDF/UA and PDF/A-3a are two effective standards for addressing these needs. This article…
Converting Office Open XML (DOCX) to PDF in Java
Learn how to convert Office Open XML (DOCX) documents to PDF in Java using the powerful ServerTextControl library. This guide provides step-by-step instructions and code examples to help you…
Extending DS Server with Custom Digital Signature APIs
In this article, we will explore how to extend the functionality of DS Server by integrating custom digital signature APIs. We will cover the necessary steps to create a plugin that allows DS…
Convert Markdown to PDF in a Console Application on Linux and Windows
Learn how to convert Markdown files to PDF in a console application on Linux and Windows using TX Text Control .NET Server for ASP.NET. This tutorial provides step-by-step instructions and code…
Mining PDFs with Regex in C#: Practical Patterns, Tips, and Ideas
Mining PDFs with Regex in C# can be a powerful technique for extracting information from documents. This article explores practical patterns, tips, and ideas for effectively using regular…