Stirling-PDF/shared-operations/functions/extractPages.ts
2023-11-08 03:33:22 +03:00

11 lines
422 B
TypeScript

import { PDFDocument } from 'pdf-lib';
import { createSubDocument } from './createSubDocument';
export async function extractPages(snapshot: string | Uint8Array | ArrayBuffer, pagesToExtractArray: number[]): Promise<Uint8Array>{
const pdfDoc = await PDFDocument.load(snapshot)
// TODO: invent a better format for pagesToExtractArray and convert it.
return createSubDocument(pdfDoc, pagesToExtractArray);
};