---
title: "Convert HTML to PDF/UA in C#"
url: https://recursiveai.org/onepdf-html/cookbook/convert-html-to-accessible-pdf-ua/
description: "Convert an HTML file to a tagged PDF with the PDF/UA-1 profile in C#. See how the title, document language, headings, and lists carry into the PDF."
version: "1.0.0"
---

# Convert HTML to PDF/UA in C#

**OnePdf.Html** is a free, open-source .NET library from Recursive AI that converts PDF to HTML and HTML to PDF. MIT or Apache-2.0, no native dependencies.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OnePdf.Html.Render) · [GitHub](https://github.com/recursive-ai-oss/onepdf-html-csharp) · [Docs](https://recursiveai.org/onepdf-html/docs/) · [Download example (.zip)](https://recursiveai.org/onepdf-html/cookbook/convert-html-to-accessible-pdf-ua/convert-html-to-accessible-pdf-ua.zip)

PDF/UA is a PDF accessibility standard that uses tags to describe the document’s structure.

```shell
dotnet add package RecursiveAI.OnePdf.Html.Render
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using OnePdf.Html.Render;

var result = HtmlToPdf.ConvertFile(
    "report.html", "report.pdf",
    new() { Profile = HtmlPdfProfile.PdfUA1 });
Console.WriteLine($"Pages: {result.PageCount}");
```

Paste the code above into Program.cs of a new `dotnet new console` project and `dotnet run`, or unzip [the example](https://recursiveai.org/onepdf-html/cookbook/convert-html-to-accessible-pdf-ua/convert-html-to-accessible-pdf-ua.zip) and `dotnet run`.

The snippet writes `report.pdf`. Save this sample as `report.html` next to `Program.cs`, or use the copy in the download:

```html
<!doctype html>
<html lang="en">
<head><title>Library hours</title></head>
<body>
  <h1>Library hours</h1>
  <ul>
    <li>Monday: 9 AM to 6 PM</li>
    <li>Tuesday: 10 AM to 6 PM</li>
  </ul>
</body>
</html>
```



`dotnet run` prints:

```text
Pages: 1
```

Open `report.pdf` to see the heading and the two list items. If a requested PDF/UA-1 rule is broken, the converter throws `HtmlToPdfException` with `Failure` set to `ProfileViolation` and lists the problems in its message.

## Variations

**Set the title and language in C#.** If you can’t edit the input’s metadata, use these options as the third argument to `ConvertFile`:

```csharp
var options = new HtmlToPdfOptions
{
    Profile = HtmlPdfProfile.PdfUA1,
    Title = "Library opening hours",
    Language = "en"
};
```

**Request PDF/A-2a as well as PDF/UA-1.** Replace the profile assignment when the same file must serve both as an accessible copy and for archiving:

```csharp
Profile = HtmlPdfProfile.PdfA2aAndUA1
```

## Related recipes

- [Create an accessible PDF without HTML](https://recursiveai.org/onepdf/cookbook/create-pdf-ua/)
- [Convert a web page to PDF](https://recursiveai.org/onepdf-html/cookbook/convert-url-to-pdf/)

---

## The short answer

To convert HTML to PDF/UA in C#, install `RecursiveAI.OnePdf.Html.Render` and call `HtmlToPdf.ConvertFile` with `Profile = HtmlPdfProfile.PdfUA1`. Give the document a title and a language. OnePdf.Html reads them from HTML’s `<title>` and `lang` by default, or from the options if you set them. Keep `HtmlToPdfOptions.Tagged` set to `true` (the default).

## What is the difference between a tagged PDF and PDF/UA?

Tags describe what the content means: a heading starts a section, a list contains items, and a table header identifies the data under it. Assistive technology can use that structure in a way it can’t use text that’s simply drawn in bold or positioned in a grid. [PDF/UA-1](https://pdfa.org/resource/iso-14289-pdfua/) specifies how to use tagged PDF for accessibility and has requirements beyond the presence of tags.

OnePdf.Html produces a tagged PDF by default. That is not the same as requesting the PDF/UA-1 profile: with `PdfUA1`, the converter writes the profile identifier and checks PDF/UA rules it can enforce. The [HTML-to-PDF guide](https://recursiveai.org/onepdf-html/docs/html-to-pdf/#links-outline-metadata-and-tags) lists what the converter carries over: headings, lists, tables with header cells, figures with alternate text, and links.

## How can I make the HTML source accessible before converting it?

Start with the document outline. Use a heading element for each section, in a logical order. Use list elements for a list and table header cells to label columns or rows of data. Keep the source in the order you want it read. For an informative image, write alternative text that conveys what someone needs to know from the image, not its filename. A converter can carry the description into the PDF, but it can’t tell if the description makes sense.

If conversion stops on a missing title or language, add the missing value to the source or supply it in C#. That fixes metadata; it doesn’t fix a heading made out of a styled paragraph. Review the reading order and details such as link labels and contrast as well. The PDF Association notes that PDF/UA conformance alone [doesn’t ensure the content is accessible](https://pdfa.org/resource/iso-14289-pdfua/#context-and-limitations).

## What is the difference between PDF/UA and PDF/A?

PDF/UA is for accessibility. [PDF/A](https://pdfa.org/resource/iso-19005-2-pdf-a-2/) is for keeping a document usable over the long term. A request for PDF/A isn’t the same as a request for PDF/UA, even when the archival profile also requires tags. If you need both, the combined `PdfA2aAndUA1` option asks the converter for both profiles in one file. The [profile guide](https://recursiveai.org/onepdf-html/docs/html-to-pdf/#pdfua-and-pdfa) notes that these profiles build the entire PDF in memory instead of streaming it, so larger PDFs need more memory.
