UNPKG

react-pdf-simple-viewer

Version:

![License](https://img.shields.io/github/license/cdx0/react-pdf-simple-viewer?style=flat-square) ![NPM](https://img.shields.io/npm/v/react-pdf-simple-viewer?style=flat-square) ![typescript](https://img.shields.io/badge/%E6%94%AF%E6%8C%81-typescript-blue?s

23 lines (20 loc) 551 B
import { PDFDocumentProxy } from 'pdfjs-dist/types/src/display/api'; export async function getPageHeight( PDF: PDFDocumentProxy, options: { index: number; width?: number; scale?: number; } ) { const page = await PDF.getPage(options.index); const WIDTH = options.width ?? page._pageInfo.view[2]; if (options.scale === undefined) { options.scale = 1; } const SCALE = (WIDTH / page._pageInfo.view[2]) * options.scale; const viewport = page.getViewport({ scale: SCALE, }); return Math.floor(viewport.height); }