diff --git a/README.md b/README.md index 1c35f15..c9afbf2 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,10 @@ Field name to value. Names are the ones `iris-pdf fields` prints. Text fields take strings, checkboxes `true`/`false`, radio groups and lists one of their options. A wrong type, an unknown option or a value over the field's length limit stops the run before anything is written. Read-only fields are skipped and counted. Unchecking always writes `/Off`, whatever the source used for "off". +### Flat forms + +A PDF with no form fields, such as a scanned form, gets them from the HTML: each ``, `', + ); + const [yes, no, city, notes] = formsOf(top); + assert.deepEqual([yes.group, no.group], ["Do you own a home?", "Do you own a home?"]); + assert.deepEqual(no.labelWords.map((w) => w.text), ["No"]); + assert.deepEqual(city.labelWords.map((w) => w.text), ["Your", "city:"]); + assert.deepEqual([city.type, city.options], ["combobox", ["a", "Boone"]]); + assert.equal(notes.type, "multiline"); }); +test("header ids are unique across a page's tables", () => { + const { top } = build("
A
1
B
2
"); + const ids: string[] = [], walk = (n: Node) => { if (n.id) ids.push(n.id); n.kids.forEach((k) => isRun(k) || walk(k)); }; + walk(top); + assert.deepEqual(ids, ["p1-th1", "p1-th2"]); +}); + +function formsOf(top: Node) { + const forms: FormRef[] = []; + const walk = (n: Node) => { if (n.form) forms.push(n.form); n.kids.forEach((k) => isRun(k) || walk(k)); }; + walk(top); + return forms; +} + test("tables: header ids, scope and each cell's headers", () => { const { top } = build( "" +
Q1Q2