Made sort and extract pages functions conform to the new design pattern. Standardised naming of a few variables

This commit is contained in:
Saud Fatayerji
2023-11-17 00:32:09 +03:00
parent 53bf6ef4bc
commit 544a080db4
15 changed files with 312 additions and 285 deletions

View File

@@ -0,0 +1,20 @@
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) {
const { file, pageIndexes } = params;
const pdfLibDocument = await file.pdfLibDocument;
var indexes = pageIndexes;
if (!Array.isArray(indexes)) {
indexes = parsePageIndexSpecification(indexes, pdfLibDocument.getPageCount());
}
return getPages(file, indexes);
}