Made sort and extract pages functions conform to the new design pattern. Standardised naming of a few variables
This commit is contained in:
20
shared-operations/src/functions/extractPages.ts
Normal file
20
shared-operations/src/functions/extractPages.ts
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user