mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-04-08 01:16:26 +02:00
23 lines
664 B
TypeScript
23 lines
664 B
TypeScript
|
|
import { PdfFile } from '../wrappers/PdfFile.js';
|
|
import { getPages } from './common/getPagesByIndex.js';
|
|
|
|
export type ExtractPagesParamsType = {
|
|
file: PdfFile;
|
|
pageIndexes: string | number[];
|
|
}
|
|
export async function extractPages(params: ExtractPagesParamsType): Promise<PdfFile> {
|
|
const { file, pageIndexes } = params;
|
|
const pdfLibDocument = await file.pdfLibDocument;
|
|
|
|
var indexes = pageIndexes;
|
|
|
|
if (!Array.isArray(indexes)) {
|
|
indexes = parsePageIndexSpecification(indexes, pdfLibDocument.getPageCount());
|
|
}
|
|
|
|
const newFile = await getPages(file, indexes);
|
|
newFile.filename += "_extractedPages"
|
|
return newFile;
|
|
}
|