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