Document accessibility pdf ua

From CraftOS-dev/craftbot-agent-bundles · View interactive version

Document accessibility pdf ua is an AI agent skill from the GitHub repository CraftOS-dev/craftbot-agent-bundles. Build and validate accessible PDFs — PDF/UA (ISO 14289), tagged PDF, WCAG 2.2 AA — using veraPDF (FOSS validator), PAC 2024 (free GUI), Adobe Acrobat Pro DC accessibility checker, axe / pa11y for HTML; conversion via Word styles → Tagged PDF, Pandoc, LibreOffice. Use when the user says "PDF/UA", "ta

How to use this skill

Skill file

Document accessibility — PDF/UA + tagged PDF + WCAG 2.2

This skill ships PDF + Office accessibility validation + remediation. The 2026 baseline is PDF/UA (ISO 14289) for PDF; WCAG 2.2 AA for HTML; Section 508 for US federal procurement.

When to use

User says:

Companion skills:

Setup

# veraPDF (FOSS PDF/A + PDF/UA validator)
# Download installer from https://verapdf.org/software/
# Or install via Homebrew:
brew install verapdf
# Or run via Docker:
docker run --rm -v $(pwd):/data verapdf/verapdf-rest

# PAC 2024 (free GUI Windows; Java CLI Mac/Linux)
# https://pac.pdf-accessibility.org/

# Adobe Acrobat Pro DC — built-in accessibility checker (paid)

# axe-core / pa11y for HTML
npm install -g pa11y axe-cli

# Pandoc (for tagged PDF via LaTeX)
brew install pandoc

# LibreOffice headless (for tagged PDF from docx)
brew install --cask libreoffice

# Python tools
pip install pdfa-validator   # alternative validator
pip install pikepdf          # programmatic PDF edit
pip install python-docx      # add alt text + heading styles

Common recipes

Recipe 1: Standards quick map

| Standard | Scope | Key rules |

|---|---|---|

| PDF/UA (ISO 14289-1) | PDF documents | Tagged tree, reading order, alt text, language, no scanned text-as-image |

| WCAG 2.2 AA | Web + HTML docs | 4 principles (POUR), 50 criteria |

| Section 508 | US fed procurement | Adopts WCAG 2.0 AA + PDF/UA |

| EAA 2025 | EU products + services from June 2025 | Reference WCAG 2.1 / EN 301 549 |

| EN 301 549 | EU accessibility for ICT | Industry baseline ≈ WCAG 2.1 |

| ATAG 2.0 | Authoring tools | Tools themselves accessible |

Recipe 2: veraPDF — validate PDF/UA-1

# Linux/Mac CLI
verapdf --flavour ua1 input.pdf
# Returns 0 if conformant; prints rule violations otherwise

# Batch + machine-readable
verapdf --flavour ua1 --format xml input.pdf > report.xml
verapdf --flavour ua1 --format json batch_dir/ > batch-report.json

Recipe 3: veraPDF — PDF/A validation (long-term archival)

# PDF/A-2b is the practical baseline (allows JPEG2000 etc.)
verapdf --flavour 2b input.pdf

PDF/A often required alongside PDF/UA for archival accessibility (e.g., government deposits).

Recipe 4: PAC 2024 (PDF Accessibility Checker)

# Windows: pac2024.exe input.pdf
# Mac/Linux: java -jar PAC-2024.jar input.pdf
# Outputs: HTML report with rule-by-rule pass/fail

PAC checks Matterhorn Protocol (PDF/UA's machine + human checks).

Recipe 5: Word → tagged PDF (preserve structure)

In Word desktop:

  1. Use Heading 1/2/3 styles for structure (not bold font).
  2. Add alt text on every image: right-click image → View Alt Text.
  3. Set table headers: Table Tools → Layout → Repeat Header Rows.
  4. Use lists via list styles (not manual bullets).
  5. Set document language: Review → Language.
  6. File → Save As → PDF → Options → Check "Document structure tags for accessibility" + "Document properties" + "Bitmap text when fonts may not be embedded".

CLI alternative (Mac/Linux):

soffice --headless --convert-to "pdf:writer_pdf_Export:SelectPdfVersion=2,UseTaggedPDF=true,ExportNotes=true,IsAddPDFTagsForAccessibility=true" input.docx

Recipe 6: pikepdf — add document metadata + lang

import pikepdf
pdf = pikepdf.open("input.pdf", allow_overwriting_input=True)
# Set top-level Lang
pdf.Root.Lang = pikepdf.String("en-US")
# Set marked = true (so reader treats as tagged)
pdf.Root.MarkInfo = pikepdf.Dictionary(Marked=True)
# Set title for accessibility (overrides "filename.pdf" in screen reader)
with pdf.open_metadata() as m:
    m["dc:title"] = "Acme MSA — 2026-06-15"
    m["dc:language"] = "en-US"
pdf.save("output.pdf")

Recipe 7: pa11y — HTML accessibility audit

pa11y https://your-app.com/proposals/123 --standard WCAG2AA --reporter cli
pa11y --standard WCAG2AA file:///$(pwd)/proposal.html

pa11y-ci runs against a list of URLs in CI:

// .pa11yci.json
{
  "defaults": {"standard": "WCAG2AA", "timeout": 30000},
  "urls": ["https://app.com/proposal/sample", "file:///dist/proposal.html"]
}

Recipe 8: axe-core — automated accessibility scan

# In Node test
npm install -D @axe-core/playwright
const { test, expect } = require("@playwright/test");
const AxeBuilder = require("@axe-core/playwright").default;

test("proposal page is accessible", async ({ page }) => {
  await page.goto("https://your-app.com/proposal/123");
  const results = await new AxeBuilder({ page }).withTags(["wcag2a","wcag2aa","wcag21aa","wcag22aa"]).analyze();
  expect(results.violations).toEqual([]);
});

Recipe 9: python-docx — bulk add alt text to images

from docx import Document
from docx.oxml.ns import qn

doc = Document("templates/master-msa.docx")
for shape in doc.inline_shapes:
    docPr = shape._inline.find(qn("wp:docPr"))
    if docPr is not None:
        docPr.set("descr", "Widget Co logo")     # alt text
        docPr.set("title", "Logo")
doc.save("templates/master-msa-accessible.docx")

Recipe 10: Manually remediate PDF in Adobe Acrobat Pro

  1. Open PDF → Tools → Accessibility → Autotag Document.
  2. Open Tags panel → drag tags into correct reading order.
  3. Right-click image tags → Properties → Alternate Text.
  4. Tools → Accessibility → Reading Order → set table headers per column.
  5. Tools → Accessibility → Accessibility Check → fix flagged issues.
  6. Save.

Re-validate via Recipe 2.

Recipe 11: Conversion pipeline — Markdown → Tagged PDF via Pandoc

# Use Pandoc with LaTeX engine that supports tagging
pandoc input.md \
  --pdf-engine=lualatex \
  --metadata title="Acme MSA" \
  --metadata lang=en-US \
  -V documentclass=article \
  -V pdfmanagement \
  -o output.pdf

# Verify
verapdf --flavour ua1 output.pdf

For complex layouts, use --pdf-engine=tectonic with accessibility package.

Recipe 12: HTML → Tagged PDF via WeasyPrint

from weasyprint import HTML, CSS
HTML("input.html").write_pdf(
    "output.pdf",
    stylesheets=[CSS(string="@page { size: A4; margin: 1in; }")],
    pdf_variant="pdf/ua-1",         # WeasyPrint 60+ supports PDF/UA
    presentational_hints=True
)

Requires WeasyPrint >= 60.

Recipe 13: CI gate — fail PR if PDFs aren't accessible

# .github/workflows/accessibility.yml
name: Accessibility CI
on: [pull_request]
jobs:
  pdf-ua:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install veraPDF
        run: |
          wget https://software.verapdf.org/releases/verapdf-installer.zip
          unzip verapdf-installer.zip
          ./verapdf-greenfield-*/verapdf-install --silent
      - name: Validate all PDFs
        run: |
          for pdf in dist/*.pdf; do
            verapdf --flavour ua1 "$pdf" || exit 1
          done

  html-wcag:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
      - run: npm install -g pa11y-ci
      - run: pa11y-ci --config .pa11yci.json

Recipe 14: Color contrast verification

# WCAG 2.2 requires 4.5:1 for body text, 3:1 for large text
def contrast_ratio(rgb1, rgb2):
    def luminance(rgb):
        r, g, b = [c/255 for c in rgb]
        r = ((r+0.055)/1.055)**2.4 if r > 0.03928 else r/12.92
        g = ((g+0.055)/1.055)**2.4 if g > 0.03928 else g/12.92
        b = ((b+0.055)/1.055)**2.4 if b > 0.03928 else b/12.92
        return 0.2126*r + 0.7152*g + 0.0722*b
    l1, l2 = luminance(rgb1), luminance(rgb2)
    return (max(l1,l2)+0.05) / (min(l1,l2)+0.05)

assert contrast_ratio((26,115,232), (255,255,255)) >= 4.5  # brand primary on white

Recipe 15: Heading-order check

from docx import Document
doc = Document("template.docx")
levels_seen = []
for para in doc.paragraphs:
    style = para.style.name
    if style.startswith("Heading "):
        levels_seen.append(int(style.split()[1]))
# Verify no skipped levels
for i in range(1, len(levels_seen)):
    if levels_seen[i] > levels_seen[i-1] + 1:
        raise ValueError(f"Heading skip: {levels_seen[i-1]} → {levels_seen[i]}")

Examples

Example 1: Federal RFP response → 508 compliance

Goal: Win government RFP requires Section 508 PDF deliverables.

Steps:

  1. Author in Word using styles + alt text (Recipe 5, 9).
  2. Export with tagging (Recipe 5).
  3. Recipe 2 — validate PDF/UA via veraPDF.
  4. Recipe 10 — fix any failures in Acrobat Pro.
  5. Recipe 6 — finalize language metadata.

Result: Compliant deliverable; no 508 reject letter.

Example 2: SaaS proposal HTML viewer — WCAG 2.2 AA

Goal: PandaDoc-style web viewer for proposals; auditable for WCAG.

Steps:

  1. Recipe 8 — axe-core in Playwright suite.
  2. Recipe 14 — contrast verification in design tokens.
  3. Recipe 7 — pa11y-ci on sample URLs in PR.

Result: PRs blocked on accessibility regressions.

Example 3: Quarterly bulk re-validation of contract archive

Goal: 5K-PDF contract repo; verify still PDF/UA after archive migration.

Steps:

  1. Recipe 2 — batch mode on full repo.
  2. Aggregate XML/JSON report.
  3. Flag failures for remediation; route via linear-mcp.

Result: Continuous accessibility health on the archive.

Edge cases / gotchas

Sources

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.