mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-06-23 07:55:07 +00:00
18 lines
676 B
TypeScript
18 lines
676 B
TypeScript
![]() |
|
||
|
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);
|
||
|
}
|