@pdf-viewer/react
Version:
The PDF Viewer component for React and Next.js
20 lines (19 loc) • 583 B
JavaScript
const a = (n, c) => {
const t = c * (Math.PI / 180);
return {
x: n.x * Math.cos(t) - n.y * Math.sin(t),
y: n.x * Math.sin(t) + n.y * Math.cos(t)
};
}, W = (n, c, t, e, h) => {
const s = t.height * e, r = t.width * e, f = t.top * e, g = t.left * e, M = n.height - f, { x: p, y: i } = a(
{ x: r, y: s },
h
), d = c.left + Math.abs(p) / 2, x = c.top + Math.abs(i) / 2, { x: y, y: u } = a({ x: g, y: M }, h), o = {
left: y,
top: u
}, P = o.left - d, I = o.top - x;
return { leftInPage: P, topInPage: I };
};
export {
W as getWordPositionInPage
};