Most web apps that "make a PDF fillable" work by uploading your contract, W-9, or tenant application to a remote server, running a desktop PDF library in a worker container, and handing back a download link. For HR forms, tax packets, and legal agreements, uploading the document in the first place is often a non-starter.
When we built the browser-local PDFFields Fillable PDF Builder, our goal was to keep the entire AcroForm pipeline (inspecting existing fields, drawing new text/checkbox/radio/dropdown widgets, flattening filled values, and extracting populated AcroForm data into Excel) running 100% client-side with pdf.js and pdf-lib.
Here are the four concrete engineering problems we hit and how we solved them.
1. Bridging Top-Left Browser Coordinates and Bottom-Left PDF Points
Browser canvases and pointer events put (0, 0) at the top-left in CSS pixels. PDF pages put (0, 0) at the bottom-left in typographic points (1 pt = 1/72 inch, so US Letter is 612 x 792 pt).
If you store widget positions in screen pixels, zooming the viewport or rendering at different devicePixelRatio values breaks every box. Instead, we keep every field normalized in [0..1] top-left coordinates in the editor state and convert only at the pdf-lib boundary:
export interface NormalizedRect { x: number; // 0..1 from left edge y: number; // 0..1 from top edge w: number; // 0..1 width fraction h: number; // 0..1 height fraction } export function normalizedToPdfPoints( rect: NormalizedRect, pageWidthPts: number, pageHeightPts: number ) { const x = rect.x * pageWidthPts; const width = rect.w * pageWidthPts; const height = rect.h * pageHeightPts; // Flip Y axis: PDF origin is bottom-left, so subtract (top + height) from page height const y = pageHeightPts - (rect.y + rect.h) * pageHeightPts; return { x, y, width, height }; } export function pdfPointsToNormalized( pdfRect: { x: number; y: number; width: number; height: number }, pageWidthPts: number, pageHeightPts: number ): NormalizedRect { return { x: pdfRect.x / pageWidthPts, y: 1 - (pdfRect.y + pdfRect.height) / pageHeightPts, w: pdfRect.width / pageWidthPts, h: pdfRect.height / pageHeightPts }; } Keeping a deterministic round-trip (pdfPointsToNormalized(normalizedToPdfPoints(r)) === r) also makes it straightforward to inspect PDFs that already contain AcroForm widgets, edit them on the canvas, and write them back cleanly without drifting a few points every save.
2. Inspecting Existing AcroForm Widgets Across Multi-Page PDFs
Many PDFs already have broken or half-finished interactive forms. In pdf-lib, a single PDFField can own multiple widget annotations (for example, radio button options placed across different coordinates or pages), and each widget points back to its parent page through an indirect object reference (widget.P()).
To map every existing widget cleanly onto the right canvas page without scanning every page's /Annots array repeatedly, we build a reference lookup table once per document:
const pages = pdfDoc.getPages(); const pageRefToIndex = new Map<string, number>(); pages.forEach((p, idx) => { pageRefToIndex.set(p.ref.toString(), idx); }); const form = pdfDoc.getForm(); for (const pdfField of form.getFields()) { const widgets = pdfField.acroField.getWidgets(); widgets.forEach((widget) => { const pRef = widget.P(); const pageIndex = pRef && pageRefToIndex.has(pRef.toString()) ? pageRefToIndex.get(pRef.toString())! : 0; const rect = widget.getRectangle(); // Convert rect -> NormalizedRect for pageIndex }); } We also clamp font size proportionally to widget height (Math.min(baseFontSize, Math.max(8, rect.height * 0.62))) when synthesizing dropdowns and single-line text boxes. Without that clamp, an 11pt default font inside a tight 14pt tax form box clips vertically in macOS Preview and Chrome's built-in PDF viewer.
3. Keeping Radio Groups, Checkboxes, and Duplicate Names Valid
Two subtle bugs show up immediately in Acrobat Reader and Apple Preview if you generate AcroForm dictionaries naively:
- Duplicate field names link widgets together: In PDF AcroForm specs, two text fields given the same name (
"date") become linked mirrors of the same value. Typing into the tenant signature date silently overwrites the landlord date on page 4. We normalize and deduplicate every non-radio field name (date,date_2,date_3) viamakeUniqueFieldName. - Radio buttons are the opposite: All options in a mutually exclusive choice (
Yes/No,Individual/LLC/S-Corp) MUST share onePDFRadioGroupwith distinct export values (optValue), added viagroup.addOptionToPage(optValue, page, rect).
4. Why Filled AcroForm PDFs Break Standard PDF-to-Excel Converters
Here is a bug we caught directly from real user files in our PDF to Excel converter:
Someone drops a filled-in 7-page interactive form PDF (for example an IRS W-9, vendor onboarding packet, or insurance application with hundreds of AcroForm fields) expecting all the typed answers in Excel. Standard text-layer extractors call page.getTextContent(), which reads static page labels ("Name", "TIN", "Address") and completely misses widget field values stored in the annotation dictionary!
In pdf.js, filled widget values live inside await page.getAnnotations() with subtype === 'Widget'. Walking those annotations across every page, filtering out unchecked boxes (fieldValue === 'Off') and unselected radio widgets, deduplicating per (pageIndex, fieldName, value), and sorting top-to-bottom by PDF rect[3] (descending Y) produces a clean structured Form Fields worksheet (Page | Field Name | Value) right alongside any static tables detected on the page:
for (const annot of annotations) { if (annot.subtype !== 'Widget') continue; const fieldName = (annot.fieldName || annot.alternativeText || '').trim(); if (!fieldName) continue; if (annot.fieldType === 'Btn') { const val = String(annot.fieldValue ?? '').trim(); if (!val || val.toLowerCase() === 'off') continue; if (annot.radioButton && annot.buttonValue && String(annot.buttonValue) !== val) continue; // Checked box or selected radio option } else { // Text or Choice widget value } } Try It Locally (Network Tab Open)
You can test the full AcroForm builder, Fill & Sign flattening, and AcroForm-to-Excel extraction right in your browser without creating an account:
- Fillable PDF Builder (AcroForm editor)
- Fill and Sign PDF locally
- PDF to Excel & Filled AcroForm Extractor
- PDFFields vs. Adobe Acrobat comparison
Open DevTools Network before dropping a file and you will see zero PDF bytes leave your browser.

