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,18 @@
import { PdfFile } from '../wrappers/PdfFile.js';
import { detectEmptyPages } from './common/detectEmptyPages.js';
import { getPages } from './common/getPagesByIndex.js';
export type RemoveBlankPagesParamsType = {
file: PdfFile;
whiteThreashold: number;
}
export async function removeBlankPages(params: RemoveBlankPagesParamsType) {
const { file, whiteThreashold } = params;
const pageCount = await file.pdfLibDocument;
const emptyPages = await detectEmptyPages(file, whiteThreashold);
console.debug("Empty Pages: ", emptyPages);
const pagesToKeep = invertSelection(emptyPages, pageCount.getPageCount())
return getPages(file, pagesToKeep);
}