refactor(annotation): update mapSignature to handle frames and signatures separately

- Modified `mapSignature` to set `name` as 'frame' for FRAME annotations and 'signature' for signature annotations.
- Added processing for annotations with `isSignature` to include their `value` from attachments if present.
- Ensures consistent mapping of form fields, frames, and signatures.
This commit is contained in:
tekh 2025-10-20 14:29:39 +02:00
parent cff79730b0
commit 04ae14c660

View File

@ -328,9 +328,16 @@ function mapSignature(iJSON) {
const preElement = findNearest(annot, e => e.bbox[0], e => e.bbox[1], ...iJSON.annotations.filter(field => field.id.includes("signature"))); const preElement = findNearest(annot, e => e.bbox[0], e => e.bbox[1], ...iJSON.annotations.filter(field => field.id.includes("signature")));
const idPartsOfPre = preElement.id.split('#'); const idPartsOfPre = preElement.id.split('#');
annot.elementId = Number(idPartsOfPre[2]); annot.elementId = Number(idPartsOfPre[2]);
annot.name = annot.description.toLowerCase(); annot.name = 'frame';
annot.value = fixBase64(iJSON.attachments[annot.imageAttachmentId]?.binary); annot.value = fixBase64(iJSON.attachments[annot.imageAttachmentId]?.binary);
return annot; return annot;
}),
signatures: iJSON.annotations.filter(annot => annot.isSignature).map(annot => {
if (annot.imageAttachmentId)
annot.value = iJSON.attachments[annot.imageAttachmentId]?.binary;
annot.name = 'signature';
return annot;
}) })
}; };
} }