Appended operation names to filenames

This commit is contained in:
Saud Fatayerji
2023-11-17 00:45:37 +03:00
parent 544a080db4
commit fa36d5d296
4 changed files with 30 additions and 27 deletions

View File

@@ -6,7 +6,7 @@ export type ExtractPagesParamsType = {
file: PdfFile;
pageIndexes: string | number[];
}
export async function extractPages(params: ExtractPagesParamsType) {
export async function extractPages(params: ExtractPagesParamsType): Promise<PdfFile> {
const { file, pageIndexes } = params;
const pdfLibDocument = await file.pdfLibDocument;
@@ -16,5 +16,7 @@ export async function extractPages(params: ExtractPagesParamsType) {
indexes = parsePageIndexSpecification(indexes, pdfLibDocument.getPageCount());
}
return getPages(file, indexes);
const newFile = await getPages(file, indexes);
newFile.filename += "_extractedPages"
return newFile;
}

View File

@@ -14,5 +14,8 @@ export async function removeBlankPages(params: RemoveBlankPagesParamsType) {
const emptyPages = await detectEmptyPages(file, whiteThreashold);
console.debug("Empty Pages: ", emptyPages);
const pagesToKeep = invertSelection(emptyPages, pageCount.getPageCount())
return getPages(file, pagesToKeep);
const newFile = await getPages(file, pagesToKeep);
newFile.filename += "_removedBlanks"
return newFile;
}

View File

@@ -18,5 +18,8 @@ export async function sortPagesWithPreset(params: SortPagesWithPresetParamsType)
const sortFunction = sorts[sortPreset];
const pageCount = pdfLibDocument.getPageCount();
const sortIndexes = sortFunction(pageCount);
return getPages(file, sortIndexes);
const newFile = await getPages(file, sortIndexes);
newFile.filename += "_sortedPages"
return newFile;
}