Add a tag structure to an untagged PDF, review it, and see what still needs work

PDF Accessibility Auto-Tagger

Load an untagged PDF and the page works out reading order, headings, paragraphs, lists, simple tables, figures and repeated headers and footers, lets you correct them, and writes a tag structure into a new copy. It is best effort: it never claims the result conforms to PDF/UA.

The result is a better starting point, not a conformant file. A program cannot judge whether alt text describes a picture or whether the reading order makes sense to a screen-reader user, and it has not been checked here with PAC, veraPDF or NVDA. Check the output with those before you rely on it.

PDF

Choose an untagged PDF

Up to 50 MB and 300 pages

Only PDFs with no tags are accepted. Pages whose content uses a stream format this page does not read are left untagged and listed afterwards.

PDF Accessibility Auto-Tagger

Operator: Abdulla Al Fahad. How tools are built and checked

A PDF exported without tags looks fine on screen and reads badly to a screen reader: the text comes out in whatever order the producer drew it, headings are not headings, and a table is a scatter of words. Tagging fixes that by adding a structure tree that says what each piece of text is and in which order to read it. This page analyses the page layout, proposes a structure, shows you the blocks on a picture of each page so you can correct them, and writes the tags into a new copy of the file. Afterwards it lists which accessibility checks pass and which still need a person.

Key features

  • Reading order by XY-cut with column detection, so a two-column page reads left column then right column
  • Headings from font size and weight, paragraphs, bullet and numbered lists as list structures with labels and bodies, and simple tables from aligned columns with a header row
  • Images and inline images found in the content and placed in reading order as figures, with alt text you type
  • Repeated headers, footers and page numbers, and every line or filled shape that carries no content, marked as artifacts
  • A review step: a numbered picture of each page, move blocks up or down, change a block's tag, flip a table's first row between header and data, or leave a block out of the tags
  • Link annotations and form fields tagged and linked to the structure, the document title, language and tab order set, and the result run through the site's PDF accessibility checker

What is written into the PDF

The page reads each page's content stream, finds the text-showing operators with their positions, and wraps them in marked-content sequences. Tagged content gets /Tag <</MCID n>> BDC ... EMC, with n counting from 0 on each page, and anything that is not content gets /Artifact BMC ...

EMC. Sequences are opened and closed inside the same text object or graphics state, so q and Q, BT and ET stay balanced.

The structure is a StructTreeRoot with one Document element, with standard types only (P, H1 to H6, L, LI, Lbl, LBody, Table, TR, TH, TD, Figure, Link and Form), a ParentTree that maps every MCID and every annotation back to its element, and an empty RoleMap. The catalog gets MarkInfo, Lang and DisplayDocTitle, and every page gets /Tabs /S.

Alt text, annotation descriptions and the title are written as hex strings, and a language code must look like en or en-US. PDFs that already have tags, an encryption password, or marked-content identifiers are refused, and pages whose content uses a stream format that is not read are left untagged and listed.

How it works

Text items come from pdf.js with their position, width and font size. They are grouped into lines by baseline, then split by XY-cut: wide gaps between lines make stacked blocks, and a wide vertical gap with several lines of wide text on each side makes columns, while narrow cells keep a table together. The most common font size is the body size; lines at least 18% larger, or short bold lines, become headings, with levels from the sizes found. Lines that start with a bullet, a number or a letter and a bracket start list items, and three or more lines whose pieces line up in two or more columns become a table.

Each show operator is matched to the pdf.js item that lies under its start position, which is how a block's items become the drawing operators to wrap. Text that cannot be matched is tagged as a paragraph of its own so nothing is left untagged. Form XObjects are marked as artifacts, so text drawn inside one is not tagged, and the result says how many there are.

Common use cases

  • A department has 30 policy PDFs exported from Word with tags switched off. The tagger gets the headings and lists right on most, and the person reviewing spends the time on the tables and on alt text instead of tagging each paragraph.
  • A two-column conference paper reads left column then right column in the tag tree, which the structure tree preview in a PDF viewer confirms.
  • A flyer has a decorative banner and a QR code. The person leaves the banner out of the tags, types a short description for the QR code, and the checker's figure alternative text check then passes.

How to use this tool

  1. Choose an untagged PDF, or press Load an example, and wait for the analysis.
  2. Step through the pages: fix the reading order, headings, table headers and anything that should be an artifact, type alt text for each figure, and set the title and language.
  3. Press Write the tags, download the copy, and read the list of what still needs a person.
  4. Open the tagged copy in a viewer that shows the tag tree, or read it with a screen reader, before it is distributed.

Example

Load an example: a two-page untagged report with a heading, a paragraph, a three-item list, a four-row table, a picture on page 1 and a footer with page numbers

The PDF has no tags, no language and no title. You type alt text for the picture and keep the proposed structure.

Before and after

The checker reports 3 failures on the original (tagged PDF, document language, title in the window). The tagged copy has 11 blocks on 2 pages (heading, paragraph, subheading, list, table, and the figure), 45 marked-content items, 6 artifact runs for the footer, the rule line and the page numbers, and the checker reports 13 passes, 1 warning (PDF/UA identifier) and 0 failures.

Tips for best results

  • Fix heading levels in the review step before writing the tags. The levels come from the sizes found in the document, so a document with only one large size gets H1 for it and H2 for the next, and you can change any of them.
  • Mark a decorative picture or a repeated logo as left out of the tags instead of inventing alt text for it.
  • Check the reading order of pages with sidebars or pull quotes first; they are the pages where the automatic order is most likely to be wrong.
  • Tag one document from a template first and read what the layout rules do with it; the same template repeated in 30 files will behave the same way.

Common pitfalls

Tables are found only from aligned text. A table drawn with ruling lines and merged cells, or with a single column, may come out as paragraphs, and headers other than the first row are not detected.

Alt text is yours to write. A figure left empty gets the word Image, which passes a presence check and helps no one.

Common errors and how to fix them

This PDF already has tags
The page only tags untagged PDFs. Remove the existing tags in a PDF editor, or check the file with the PDF accessibility checker to see what is wrong with them.
This PDF has no selectable text
It is probably a scan. Make it searchable with OCR first, then choose the searchable copy.
Page 4 was left untagged because its content stream uses a filter that is not read
Re-save the PDF from a PDF editor or print it to PDF to rewrite its streams in a standard form, then tag it again.

Best practices

  • Read down the reading order once for each kind of page in a template, such as a cover, a two-column page and a table page; a template repeated across many files then needs the check only once.

What the layout analysis cannot see

It works from the text items pdf.js reports and the drawing operators in the page. Text drawn as outlines or pictures has no text to tag, and text drawn inside a form XObject is marked as an artifact with the rest of that object. Rotated text, tables drawn with ruling lines and merged cells, footnotes and text that flows around a picture are read by the same line and column rules as ordinary text, so they are the blocks to check first in the review step.

Frequently asked questions

Will the result pass PDF/UA?

The page does not claim it, and it has not been tested with PAC or veraPDF here. A program cannot judge whether alt text describes a figure or whether the reading order helps a reader, and PDF/UA also needs XMP metadata and other details that are not written. On the example, the site's own accessibility checker gave 13 passes, one warning for the PDF/UA identifier and no failures, and pdf.js read the structure tree and mapped every marked-content item to its element. Treat that as a sign the tags are well formed, not as conformance.

How well does the layout analysis work on real documents?

It was exercised on generated test files, not a real corpus: a report with a heading, list, table and picture, and a two-column page. It handled both. Real documents have footnotes, sidebars, tables with merged cells and mixed fonts, which is why the review step exists; plan on correcting some blocks.