Cleanup, Documented Impose

This commit is contained in:
Felix Kaspar
2023-11-17 20:38:45 +01:00
parent 432342415e
commit 8a63ebe6cf
7 changed files with 30 additions and 21 deletions

View File

@@ -5,19 +5,19 @@ import { parsePageIndexSpecification } from './common/pageIndexesUtils'
export type ExtractPagesParamsType = {
file: PdfFile;
pageIndexes: string | number[];
pageIndecies: string | number[];
}
export async function extractPages(params: ExtractPagesParamsType): Promise<PdfFile> {
const { file, pageIndexes } = params;
const { file, pageIndecies: pageIndecies } = params;
const pdfLibDocument = await file.pdfLibDocument;
var indexes = pageIndexes;
var indecies = pageIndecies;
if (!Array.isArray(indexes)) {
indexes = parsePageIndexSpecification(indexes, pdfLibDocument.getPageCount());
if (!Array.isArray(indecies)) {
indecies = parsePageIndexSpecification(indecies, pdfLibDocument.getPageCount());
}
const newFile = await getPages(file, indexes);
const newFile = await getPages(file, indecies);
newFile.filename += "_extractedPages"
return newFile;
}