From 18b32b9224fa4f5349b1ab4680567d821f6ae089 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 13 Jun 2026 00:21:21 +0000 Subject: [PATCH 1/4] Initial plan From f70af9cd20ca1044c4c646a68efc492cd490643d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 13 Jun 2026 00:26:05 +0000 Subject: [PATCH 2/4] Normalize nullish AcroForm text values --- lib/mixins/acroform.js | 8 ++++++-- tests/unit/acroform.spec.js | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/mixins/acroform.js b/lib/mixins/acroform.js index e3dd0bb0f..814559541 100644 --- a/lib/mixins/acroform.js +++ b/lib/mixins/acroform.js @@ -368,8 +368,12 @@ export default { } Object.keys(VALUE_MAP).forEach((key) => { - if (options[key] !== undefined) { - options[VALUE_MAP[key]] = options[key]; + if (key in options) { + if (options[key] == null) { + options[VALUE_MAP[key]] = new String(''); + } else { + options[VALUE_MAP[key]] = options[key]; + } delete options[key]; } }); diff --git a/tests/unit/acroform.spec.js b/tests/unit/acroform.spec.js index e6cde61e2..d7fc9db63 100644 --- a/tests/unit/acroform.spec.js +++ b/tests/unit/acroform.spec.js @@ -186,6 +186,24 @@ describe('acroform', () => { expect(docData.length).toBe(3); expect(docData).toContainChunk(expected); }); + + test.each([ + ['undefined', undefined], + ['null', null], + ])('nullish %s value uses an empty string', (_label, value) => { + const expectedDoc = new PDFDocument({ + info: { CreationDate: new Date(Date.UTC(2018, 1, 1)) }, + }); + expectedDoc.initForm(); + const expectedDocData = logData(expectedDoc); + expectedDoc.formText('empty', 20, 20, 50, 20, { value: '' }); + + doc.initForm(); + const docData = logData(doc); + doc.formText('empty', 20, 20, 50, 20, { value }); + + expect(docData).toContainChunk(expectedDocData); + }); }); test('flags', () => { From 407ec0a73c43308938f655c9750fca9fc4df71c4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 13 Jun 2026 00:28:00 +0000 Subject: [PATCH 3/4] Address AcroForm review feedback --- lib/mixins/acroform.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mixins/acroform.js b/lib/mixins/acroform.js index 814559541..555f776b1 100644 --- a/lib/mixins/acroform.js +++ b/lib/mixins/acroform.js @@ -370,7 +370,7 @@ export default { Object.keys(VALUE_MAP).forEach((key) => { if (key in options) { if (options[key] == null) { - options[VALUE_MAP[key]] = new String(''); + options[VALUE_MAP[key]] = ''; } else { options[VALUE_MAP[key]] = options[key]; } From 0c92a0e2424e598cfda13c84f96b52ac1f9bc96d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 13 Jun 2026 00:35:05 +0000 Subject: [PATCH 4/4] Simplify AcroForm value normalization --- lib/mixins/acroform.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/mixins/acroform.js b/lib/mixins/acroform.js index 555f776b1..4933acb8f 100644 --- a/lib/mixins/acroform.js +++ b/lib/mixins/acroform.js @@ -369,11 +369,7 @@ export default { Object.keys(VALUE_MAP).forEach((key) => { if (key in options) { - if (options[key] == null) { - options[VALUE_MAP[key]] = ''; - } else { - options[VALUE_MAP[key]] = options[key]; - } + options[VALUE_MAP[key]] = options[key] ?? ''; delete options[key]; } });