fix(annotations): include bounding box coordinates in mapped signature and frame data
- Added extraction of `x`, `y`, `width`, and `height` from annotations and frames in `mapSignature`. - Ensures positional data is correctly preserved when mapping signatures and frames from PSPDFKit annotations. - No functional changes to annotation creation, deletion, or validation.
This commit is contained in:
parent
39c12ada45
commit
6feb601670
@ -321,7 +321,7 @@ function mapSignature(iJSON) {
|
||||
// formFields
|
||||
...iJSON.formFieldValues.filter(field => !field.name.includes("label")).map((field) => {
|
||||
const nameParts = field.name.split('#');
|
||||
const [x, y, width, height] = iJSON.annotations.find(iAnnot => iAnnot.id === field.name)?.bbox;
|
||||
const [x, y, width, height] = iJSON.annotations.find(iAnnot => iAnnot.id === field.name).bbox;
|
||||
return {
|
||||
elementId: Number(nameParts[2]),
|
||||
name: nameParts[3],
|
||||
@ -340,11 +340,16 @@ function mapSignature(iJSON) {
|
||||
field => field.id.includes("signature") && field.pageIndex === annot.pageIndex
|
||||
));
|
||||
const idPartsOfPre = preElement.id.split('#');
|
||||
const [x, y, width, height] = annot.bbox;
|
||||
return {
|
||||
elementId: Number(idPartsOfPre[2]),
|
||||
name: 'frame',
|
||||
value: fixBase64(iJSON.attachments[annot.imageAttachmentId]?.binary),
|
||||
type: annot.type
|
||||
type: annot.type,
|
||||
x: x,
|
||||
y: y,
|
||||
width: width,
|
||||
height: height
|
||||
};
|
||||
}),
|
||||
|
||||
@ -366,11 +371,16 @@ function mapSignature(iJSON) {
|
||||
else
|
||||
throw new Error("Signature mapping failed: The data structure from the third-party library is incompatible or missing required fields.");
|
||||
|
||||
const [x, y, width, height] = annot.bbox;
|
||||
return {
|
||||
elementId: Number(idPartsOfPre[2]),
|
||||
name: 'signature',
|
||||
value,
|
||||
type: annot.type
|
||||
type: annot.type,
|
||||
x: x,
|
||||
y: y,
|
||||
width: width,
|
||||
height: height
|
||||
};
|
||||
})
|
||||
];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user