From a980558147bd12a9b29df0786f7bccbb55218a80 Mon Sep 17 00:00:00 2001 From: Andrew Dillon Date: Fri, 9 Oct 2020 16:30:22 -0500 Subject: [PATCH] Return false for PDFSignature.needsAppearancesUpdate --- assets/pdfs/with_signature.pdf | Bin 0 -> 12071 bytes src/api/form/PDFSignature.ts | 4 ++++ tests/api/form/PDFForm.spec.ts | 16 ++++++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 assets/pdfs/with_signature.pdf diff --git a/assets/pdfs/with_signature.pdf b/assets/pdfs/with_signature.pdf new file mode 100644 index 0000000000000000000000000000000000000000..193a2b68dac04a1b9033b28ab2f1042c91a44224 GIT binary patch literal 12071 zcmeHtXH=BSvNjn+P%=tp2$Cn0BxjJEgJgyb1H+I(vVfAK1j#`_MNmKl36dlSK?DR* zqDT^iA<7-yd#mSc&;9nd*8O>AEm%F>Rn=9`Tiw%7z0IYqpd<(u5+>*RurU0JoD>RY z1F<1(oXI65fJ#oTXaowV$+#S%4Y*2`ZC{UA46sYg- zfdFdRIP0O^q@=viD1@~eIjQ4ZbCwyBsfRM^tWQFXWby7=AU+=MRGbxijbKbI!VYvX z?P-}vK?YtOY0=41Zgs$GHLFYh{rC<6fk(RLnR?~f>{`1tYjzbHh3bVfG!Yi&A$p`o zaIMnUywmz>uQJPg^UKS%d^3kxHdJ(=g*$Lk!+RD`!ZENqrS3w#E`(uyw~;6^ z*+ab`RfOaecX7vjun&=7*38cjI?lmahi_TDJM)up9JxU{TK<$o07CPkw!EUD<#@Sk zY2qs^s%A%IlC@=))jdS=qg}mQNOoQ)Wb3BfZQ#z{BRZ zO(|)H@+@?2Pw}xwL!zFCSzr%latjj@gjTwKmu0`)w{^3nHN-C@c*Puf6YZ4e3)GzS zjrJW*Xz)FDnlrz-da^`X1@hs%cX)`ll*V@Y2yKH5_d}-%F`X0;8&&ZON zAdZIdp|j`W;P%PKgs^nn9QL8H^*Mpv6o;sECbn^aSv_3CGAf4Dpm#fHBxl^%-n(y>N}{mVeV1U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ts @@ -46,4 +46,8 @@ export default class PDFSignature extends PDFField { this.acroField = acroSignature; } + + needsAppearancesUpdate() { + return false; + } } diff --git a/tests/api/form/PDFForm.spec.ts b/tests/api/form/PDFForm.spec.ts index 0a1d3bc1d..fe33a48e3 100644 --- a/tests/api/form/PDFForm.spec.ts +++ b/tests/api/form/PDFForm.spec.ts @@ -47,6 +47,7 @@ const fancyFieldsPdfBytes = fs.readFileSync('assets/pdfs/fancy_fields.pdf'); // const combedPdfBytes = fs.readFileSync('assets/pdfs/with_combed_fields.pdf'); // const dodPdfBytes = fs.readFileSync('assets/pdfs/dod_character.pdf'); const xfaPdfBytes = fs.readFileSync('assets/pdfs/with_xfa_fields.pdf'); +const signaturePdfBytes = fs.readFileSync('assets/pdfs/with_signature.pdf'); describe(`PDFForm`, () => { const origConsoleWarn = console.warn; @@ -275,6 +276,21 @@ describe(`PDFForm`, () => { expect(aps()).toBe(20); }); + it.only(`does not throw errors for PDFSignature fields`, async () => { + const pdfDoc = await PDFDocument.load(signaturePdfBytes); + + const widgets = getWidgets(pdfDoc); + expect(widgets.length).toBe(1); + + const form = pdfDoc.getForm(); + + expect(() => form.updateFieldAppearances()).not.toThrow(); + + expect( + pdfDoc.save({ updateFieldAppearances: true }), + ).resolves.toBeInstanceOf(Uint8Array); + }); + // TODO: Add method to remove APs and use `NeedsAppearances`? How would this // work with RadioGroups? Just set the APs to `null`but keep the keys? });