---
title: "Implementing form filling and accessibility in the Firefox PDF viewer"
description: "Firefox's PDF.js viewer gained AcroForm filling, embedded-JavaScript execution, XFA form rendering and tagged-PDF accessibility."
url: "https://swe.quest/articles/implementing-form-filling-and-accessibility-in-the-firefox-pdf-viewer-eb3fe6888e1c99ce"
canonical: "https://hacks.mozilla.org/2021/10/implementing-form-filling-and-accessibility-in-the-firefox-pdf-viewer/"
source: "Mozilla Hacks"
published: "2021-10-07"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 12
tags: ["browsers","accessibility","sandboxing","javascript","testing"]
---

# Implementing form filling and accessibility in the Firefox PDF viewer

A post on [Mozilla Hacks](https://swe.quest/sources/mozilla-hacks.md), published 2021-10-07, 12 min read, Deep dive. Original: [https://hacks.mozilla.org/2021/10/implementing-form-filling-and-accessibility-in-the-firefox-pdf-viewer/](https://hacks.mozilla.org/2021/10/implementing-form-filling-and-accessibility-in-the-firefox-pdf-viewer/)

## Summary

Firefox's PDF.js viewer gained AcroForm filling, embedded-JavaScript execution, XFA form rendering and tagged-PDF accessibility. Filled AcroForm values are held in an annotationStorage object and turned into PDF appearance streams so saving and printing share one code path. PDF JavaScript runs in a null-principal ComponentUtils.Sandbox in Firefox and in a WebAssembly build of QuickJS on the web, with I/O APIs deliberately left out. XFA required a custom layout engine plus shipped Liberation fonts with rescaled glyph widths, tagged PDFs are exposed to screen readers through ARIA nodes and aria-owns links into the text layer, and regressions are caught with reftests over a crawled corpus of tens of thousands of PDFs.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Browsers](https://swe.quest/tags/browsers.md) (Web & mobile)
- [Accessibility](https://swe.quest/tags/accessibility.md) (Web & mobile)
- [Sandboxing & isolation](https://swe.quest/tags/sandboxing.md) (Security)
- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)
- [Testing](https://swe.quest/tags/testing.md) (Engineering practices)

## Prerequisites

- HTML DOM and canvas
- Web workers
- ARIA basics

## Keywords

PDF.js, Firefox, XFA, AcroForms, QuickJS, Tagged PDF, ComponentUtils.Sandbox, WebAssembly

## Related posts

- [Experimenting with local alt text generation in Firefox Nightly](https://swe.quest/articles/experimenting-with-local-alt-text-generation-in-firefox-nightly-d486bd54cc20de2e.md): Mozilla Hacks · 2024-05-31 · Medium · 9 min read · Inference & serving, Accessibility, Browsers, Computer vision, WebAssembly
  Firefox 130 adds experimental on-device alt text generation for images in the built-in PDF editor, using a 182M-parameter ViT image encoder paired with DistilGPT-2, fine-tuned on COCO, quantized to under 200MB and running in a few seconds on a laptop CPU.
- [WebKit Features in Safari 16.0](https://swe.quest/articles/webkit-features-in-safari-16-0-e20c6c1e305e84fe.md): WebKit · 2022-09-12 · Easy · 10 min read · Browsers, CSS, Identity & auth, Accessibility, Developer tools
  Safari 16.0 ships AVIF images on iOS, passkeys built on WebAuthn, CSS Container Queries (size queries and cq\* units), Subgrid, Offset Path animation, overscroll-behavior, Shared Workers, and Web Inspector Extensions, plus a new Flexbox Inspector.
- [In March, we see Firefox 87](https://swe.quest/articles/in-march-we-see-firefox-87-89133003c9c65b13.md): Mozilla Hacks · 2021-03-23 · Medium · 4 min read · Browsers, Privacy, Developer tools, Accessibility
  Firefox 87 enables the beforeinput event and InputEvent.getTargetRanges() by default, letting web apps inspect and cancel text edits in inputs and contenteditable elements before the DOM changes, with an example that protects metadata spans inside an editable comment.
- [Getting lively with Firefox 90](https://swe.quest/articles/getting-lively-with-firefox-90-e2cf4b92d9ecbff1.md): Mozilla Hacks · 2021-07-13 · Medium · 3 min read · Browsers, JavaScript, Frontend
  Firefox 90 enables JavaScript private class fields and methods by default, using a # prefix so properties can only be read or written inside the class body, and adds the relative-indexing at() method to Array, String and TypedArray, which accepts negative indexes to count from the end.
- [Intent to Ship: JPEG XL](https://swe.quest/articles/intent-to-ship-jpeg-xl-8daff64ea64e35d6.md): Mozilla Hacks · 2026-08-24 · Easy · 3 min read · Browsers, Web performance, Rust, Memory safety
  Firefox intends to ship JPEG XL support, built on jxl-rs, a Rust decoder written by Google Research in place of the earlier 100,000-line multithreaded C++ library to reduce attack surface.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
