@pdf-viewer/react
Version:
A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.
20 lines (19 loc) • 672 B
JavaScript
import { AnnotationMode as h } from "pdfjs-dist";
const l = (e, t, s = {}) => {
const { scale: i = 1, rotate: r = 0, renderForms: w = !1, interactiveForm: a = !0 } = s, c = t.getContext("2d", {
desynchronized: !1
}), p = window.devicePixelRatio, n = e.getViewport({ scale: i, rotation: r }), o = e.getViewport({
scale: i * p,
rotation: r
});
t.width = o.width, t.height = o.height, t.style.width = `${Math.floor(n.width)}px`, t.style.height = `${Math.floor(n.height)}px`;
let d = w ? h.ENABLE_FORMS : void 0;
return a || (d = h.ENABLE), e.render({
canvasContext: c,
viewport: o,
annotationMode: d
});
};
export {
l as renderPage
};