UNPKG

@pdf-viewer/react

Version:

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

18 lines (17 loc) 611 B
import { AnnotationMode as a } from "pdfjs-dist"; const p = (o, t, d = {}) => { const { scale: i = 1, rotate: r = 0, renderForms: h = !1 } = d, s = t.getContext("2d", { desynchronized: !1 }), w = window.devicePixelRatio, n = o.getViewport({ scale: i, rotation: r }), e = o.getViewport({ scale: i * w, rotation: r }); return t.width = e.width, t.height = e.height, t.style.width = `${Math.floor(n.width)}px`, t.style.height = `${Math.floor(n.height)}px`, o.render({ canvasContext: s, viewport: e, annotationMode: h ? a.ENABLE_FORMS : void 0 }); }; export { p as renderPage };