Adding PDF/UA tags to PDFs made with WeasyPrint
WeasyPrint turns HTML into good-looking PDFs, but by default those PDFs have no tags. Tags are the hidden structure that tells a screen reader “this is a heading, this is a table, this is a link”. Without them, accessibility checkers such as veraPDF or PAC mark the file as failing PDF/UA, the standard for accessible PDF.
There are two ways to fix it: have WeasyPrint write tags when it makes the PDF, or add tags to PDFs you already have.
If you can regenerate the PDF: try WeasyPrint’s PDF/UA option
WeasyPrint can write a tagged PDF itself. Pass --pdf-variant pdf/ua-1 on the command line, or pdf_variant="pdf/ua-1" to HTML.write_pdf() in Python. If you only need tags, not the full PDF/UA variant, WeasyPrint 66 and later also have --pdf-tags (pdf_tags=True). The HTML needs a <title> and a lang attribute on <html>, and a clean heading and table structure, because the PDF’s structure is built from it.
- WeasyPrint’s documentation says the result “is not guaranteed” to be valid; it depends on the HTML and CSS you use (WeasyPrint docs).
- Known gaps are tracked in WeasyPrint issue #2482, open as of September 2026: links to anchors inside the document, tags for
<figure>and<dl>,aria-*attributes, and structure split across page breaks, among others.
If you’re on WeasyPrint 57 or later and control the HTML, this is the first thing to try. Run veraPDF on the output to see what’s left.
If the PDFs already exist: tag them afterwards
Often you can’t regenerate. The files were made years ago by an older WeasyPrint, or they come out of a tool that uses WeasyPrint inside and doesn’t expose the option, or you have a folder of them to fix now.
For those, our PDF/UA Auto-Tagger adds the tags to the finished PDF. Give it links to your PDFs and it adds headings, paragraphs, lists, tables, links, the document language and title. In our test of 40 real-world PDFs, 39 looked exactly the same afterwards; in the other, one logo made of mirrored letters shifted slightly. It runs the open-source veraPDF checker on each file before and after, so you get the tagged PDF and a report of what now passes and what still needs a person. Already-tagged PDFs keep their tags; the tool only fills in missing document details such as the PDF/UA identifier and language (or, if you choose, just checks them). Scanned PDFs need OCR first, and fillable forms and password-protected files aren’t supported.
RFC 9562, the 46-page UUID standard published by the IETF, is made with xml2rfc, which uses WeasyPrint (the file says “Producer: WeasyPrint 56.1” and has no tags). As published, it failed 12 veraPDF PDF/UA-1 rules. After one run of the tagger, it failed none.
What still needs a person
Passing veraPDF means the file passes the automated PDF/UA-1 checks, the part a machine can verify. It doesn’t make a document compliant with accessibility law on its own. Someone still needs to check:
- Image descriptions. The report lists every figure by page. Write alt text for each one and give it to the tool, which adds it to the PDF.
- Reading order and heading levels. Check that they match what a reader would expect.
Last updated 26 September 2026. Something wrong or out of date? [email protected]