mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-02-25 00:17:57 +01:00
Fixed compile errors from last commit
This commit is contained in:
parent
4c8a85726d
commit
a93c575b05
@ -54,7 +54,7 @@ registerEndpoint("/merge-pdfs", "", upload.any(), Operations.mergePDFs, Joi.obje
|
||||
files: Joi.array().items(PdfFileSchema).required(),
|
||||
}).required());
|
||||
|
||||
registerEndpoint("/split-pdf", "_split", upload.single("file"), Operations.splitPDF, Joi.object({
|
||||
registerEndpoint("/split-pdf", "_split", upload.single("file"), Operations.splitPdfByIndex, Joi.object({
|
||||
file: PdfFileSchema.required(),
|
||||
pageNumbers: Joi.string().required(),
|
||||
}).required());
|
||||
|
@ -4,12 +4,12 @@ import { splitPagesByIndex } from "./common/splitPagesByIndex.js";
|
||||
import { detectEmptyPages } from "./common/detectEmptyPages.js";
|
||||
import { detectQRCodePages } from "./common/detectQRCodePages.js";
|
||||
|
||||
export type SplitOnParamsType = {
|
||||
export type SplitPageByPresetParamsType = {
|
||||
file: PdfFile;
|
||||
type: "BAR_CODE"|"QR_CODE"|"BLANK_PAGE";
|
||||
whiteThreashold?: number;
|
||||
}
|
||||
export async function splitPagesByPreset(params: SplitOnParamsType): Promise<PdfFile[]> {
|
||||
export async function splitPagesByPreset(params: SplitPageByPresetParamsType): Promise<PdfFile[]> {
|
||||
const { file, type, whiteThreashold } = params;
|
||||
|
||||
console.log("File: ", file);
|
||||
|
@ -3,11 +3,11 @@ import { PdfFile } from '../wrappers/PdfFile.js';
|
||||
import { parsePageIndexSpecification } from './common/pageIndexesUtils'
|
||||
import { splitPagesByIndex } from './common/splitPagesByIndex.js';
|
||||
|
||||
export type SplitPagesParamsType = {
|
||||
export type SplitPdfByIndexParamsType = {
|
||||
file: PdfFile;
|
||||
pageIndexes: string | number[];
|
||||
}
|
||||
export async function splitPdfByIndex(params: SplitPagesParamsType): Promise<PdfFile[]> {
|
||||
export async function splitPdfByIndex(params: SplitPdfByIndexParamsType): Promise<PdfFile[]> {
|
||||
const { file, pageIndexes } = params;
|
||||
const pdfLibDocument = await file.pdfLibDocument;
|
||||
|
||||
|
@ -7,8 +7,8 @@ import { rotatePages, RotateParamsType } from './functions/rotatePages';
|
||||
import { scaleContent, ScaleContentParamsType} from './functions/scaleContent';
|
||||
import { scalePage, ScalePageParamsType } from './functions/scalePage';
|
||||
import { sortPagesWithPreset, SortPagesWithPresetParamsType } from './functions/sortPagesWithPreset'
|
||||
import { splitOn, SplitOnParamsType } from './functions/splitOn';
|
||||
import { splitPDF, SplitPdfParamsType } from './functions/splitPDF';
|
||||
import { splitPagesByPreset, SplitPageByPresetParamsType } from './functions/splitPagesByPreset';
|
||||
import { splitPdfByIndex, SplitPdfByIndexParamsType } from './functions/splitPdfByIndex';
|
||||
import { updateMetadata, UpdateMetadataParams } from "./functions/updateMetadata";
|
||||
import { PdfFile } from "./wrappers/PdfFile";
|
||||
|
||||
@ -25,8 +25,8 @@ const toExport = {
|
||||
scaleContent,
|
||||
scalePage,
|
||||
sortPagesWithPreset,
|
||||
splitOn,
|
||||
splitPDF,
|
||||
splitPagesByPreset,
|
||||
splitPdfByIndex,
|
||||
updateMetadata,
|
||||
}
|
||||
export default toExport;
|
||||
@ -40,8 +40,8 @@ export type OperationsParametersBaseType = {
|
||||
scaleContent: ScaleContentParamsType;
|
||||
scalePage: ScalePageParamsType;
|
||||
sortPagesWithPreset: SortPagesWithPresetParamsType;
|
||||
splitOn: SplitOnParamsType;
|
||||
splitPDF: SplitPdfParamsType;
|
||||
splitPagesByPreset: SplitPageByPresetParamsType;
|
||||
splitPdfByIndex: SplitPdfByIndexParamsType;
|
||||
updateMetadata: UpdateMetadataParams;
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ export async function * traverseOperations(operations: Action[], input: PdfFile[
|
||||
case "split":
|
||||
// TODO: A split might break the done condition, it may count multiple times. Needs further testing!
|
||||
yield* oneToN(input, action, async (input) => {
|
||||
const splitResult = await Operations.splitPDF({file: input, splitAfterPageArray: action.values["splitAfterPageArray"]});
|
||||
const splitResult = await Operations.splitPdfByIndex({file: input, pageIndexes: action.values["splitAfterPageArray"]});
|
||||
for (let j = 0; j < splitResult.length; j++) {
|
||||
splitResult[j].filename = splitResult[j].filename + "_split" + j;
|
||||
}
|
||||
@ -100,7 +100,7 @@ export async function * traverseOperations(operations: Action[], input: PdfFile[
|
||||
break;
|
||||
case "splitOn":
|
||||
yield* oneToN(input, action, async (input) => {
|
||||
const splitResult = await Operations.splitOn({file: input, type: action.values["type"], whiteThreashold: action.values["whiteThreashold"]});
|
||||
const splitResult = await Operations.splitPagesByPreset({file: input, type: action.values["type"], whiteThreashold: action.values["whiteThreashold"]});
|
||||
for (let j = 0; j < splitResult.length; j++) {
|
||||
splitResult[j].filename = splitResult[j].filename + "_split" + j;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user