2023-10-26 20:53:02 +02:00
|
|
|
|
2023-10-26 22:41:48 +02:00
|
|
|
import { PDFDocument } from 'pdf-lib';
|
2023-11-08 02:24:16 +01:00
|
|
|
import { createSubDocument } from './common/createSubDocument';
|
2023-10-26 20:53:02 +02:00
|
|
|
|
2023-11-08 01:33:22 +01:00
|
|
|
export async function extractPages(snapshot: string | Uint8Array | ArrayBuffer, pagesToExtractArray: number[]): Promise<Uint8Array>{
|
2023-10-26 22:41:48 +02:00
|
|
|
const pdfDoc = await PDFDocument.load(snapshot)
|
2023-10-17 03:40:54 +02:00
|
|
|
|
|
|
|
// TODO: invent a better format for pagesToExtractArray and convert it.
|
2023-10-26 20:53:02 +02:00
|
|
|
return createSubDocument(pdfDoc, pagesToExtractArray);
|
2023-10-17 03:40:54 +02:00
|
|
|
};
|