TekH 038ac2aed0 fix(annotations): correct signature frame mapping by filtering by pageIndex
- Updated `mapSignature` to filter signature annotations by `pageIndex` when finding nearest elements.
- Ensures correct association of frames and signature data for each page.
- Prevents errors caused by cross-page annotation references.
2025-10-28 12:59:49 +01:00

26 lines
880 B
JavaScript

const B64ToBuff = (base64String) => new Uint8Array(Array.from(atob(base64String), char => char.charCodeAt(0))).buffer;
const getLocaleDateString = _ => new Date().toLocaleDateString('de-DE')
function detailedCurrentDate() {
return new Intl.DateTimeFormat('de-DE', {
day: '2-digit',
month: '2-digit',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
timeZoneName: 'shortOffset'
}).format();
}
function findNearest(origin, getX, getY, dests) {
const distanceToOrigin = (point) => Math.sqrt((getX(origin) - getX(point))**2 + (getY(origin) - getY(point))**2);
return dests.reduce(
(nearest, dest) => {
const dist = distanceToOrigin(dest);
return dist < nearest.dist ? {dist, dest} : nearest;
},
{dist: Infinity, dest: null}
).dest;
}