Skip to content

Commit

Permalink
🧪
Browse files Browse the repository at this point in the history
  • Loading branch information
vbuch committed Nov 14, 2023
1 parent 78d9c6c commit 0f0fb63
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/placeholder-pdf-lib/src/pdflibAddPlaceholder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,27 @@ describe(pdflibAddPlaceholder, () => {
expect(newAcroFormRef.tag).toBe(existingAcroFormTag);
});

it('does not overwrite page annotations when there already were some', async () => {
const input = readTestResource('signed-once.pdf');
expect(input.indexOf('/ByteRange')).not.toBe(-1);
const pdfDoc = await PDFDocument.load(input);
const existingAnnotations = pdfDoc
.getPage(0).node
.lookup(PDFName.of('Annots'), PDFArray)
.asArray().map((v) => v.toString());

pdflibAddPlaceholder({
pdfDoc,
...defaults,
});

const newAnnotations = pdfDoc
.getPage(0).node
.lookup(PDFName.of('Annots'), PDFArray)
.asArray().map((v) => v.toString());
expect(newAnnotations).toEqual(expect.arrayContaining(existingAnnotations));
expect(newAnnotations).toHaveLength(existingAnnotations.length + 1);
});

it.todo('adds placeholder to PDFDocument document when AcroForm is already there');
});

0 comments on commit 0f0fb63

Please sign in to comment.