UNPKG

@pdfme/converter

Version:

TypeScript base PDF generator and React base UI. Open source, developed by the community, and completely free to use under the MIT license!

14 lines 585 B
import { pt2mm } from '@pdfme/common'; export async function pdf2size(pdf, options = {}, env) { const { scale = 1 } = options; const { getDocument } = env; const pdfDoc = await getDocument(pdf); const promises = Promise.all(new Array(pdfDoc.numPages).fill('').map(async (_, i) => { return await pdfDoc.getPage(i + 1).then((page) => { const { height, width } = page.getViewport({ scale, rotation: 0 }); return { height: pt2mm(height), width: pt2mm(width) }; }); })); return promises; } //# sourceMappingURL=pdf2size.js.map