UNPKG

@pdf-viewer/react

Version:

A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.

26 lines (25 loc) 1.15 kB
const a = (i, h, l, o, n) => { const c = l.height * o, s = l.width * o, y = l.bottom * o, m = l.left * o, d = { width: n % 180 === 90 ? i.height : i.width, height: n % 180 === 90 ? i.width : i.height }, r = { width: n % 180 === 90 ? c : s, height: n % 180 === 90 ? s : c }, t = document.createElement("div"); t.style.width = `${d.width}px`, t.style.height = `${d.height}px`, t.style.position = "absolute", t.style.transform = `rotate(${n}deg)`, t.style.transformOrigin = "center center", t.style.visibility = "hidden", t.style.left = "-99999px"; const e = document.createElement("div"); e.style.position = "absolute", e.style.width = `${s}px`, e.style.height = `${c}px`, e.style.position = "absolute", e.style.bottom = `${y}px`, e.style.left = `${m}px`, t.appendChild(e), h.appendChild(t); const g = t.getBoundingClientRect(), p = e.getBoundingClientRect(); h.removeChild(t); const u = { top: h.clientHeight / 2, left: h.clientWidth / 2 }; return { leftInPage: p.left - g.left - u.left + r.width / 2, topInPage: p.top - g.top - u.top + r.height / 2 }; }; export { a as getWordPositionInPage };