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(),
|
files: Joi.array().items(PdfFileSchema).required(),
|
||||||
}).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(),
|
file: PdfFileSchema.required(),
|
||||||
pageNumbers: Joi.string().required(),
|
pageNumbers: Joi.string().required(),
|
||||||
}).required());
|
}).required());
|
||||||
|
@ -4,12 +4,12 @@ import { splitPagesByIndex } from "./common/splitPagesByIndex.js";
|
|||||||
import { detectEmptyPages } from "./common/detectEmptyPages.js";
|
import { detectEmptyPages } from "./common/detectEmptyPages.js";
|
||||||
import { detectQRCodePages } from "./common/detectQRCodePages.js";
|
import { detectQRCodePages } from "./common/detectQRCodePages.js";
|
||||||
|
|
||||||
export type SplitOnParamsType = {
|
export type SplitPageByPresetParamsType = {
|
||||||
file: PdfFile;
|
file: PdfFile;
|
||||||
type: "BAR_CODE"|"QR_CODE"|"BLANK_PAGE";
|
type: "BAR_CODE"|"QR_CODE"|"BLANK_PAGE";
|
||||||
whiteThreashold?: number;
|
whiteThreashold?: number;
|
||||||
}
|
}
|
||||||
export async function splitPagesByPreset(params: SplitOnParamsType): Promise<PdfFile[]> {
|
export async function splitPagesByPreset(params: SplitPageByPresetParamsType): Promise<PdfFile[]> {
|
||||||
const { file, type, whiteThreashold } = params;
|
const { file, type, whiteThreashold } = params;
|
||||||
|
|
||||||
console.log("File: ", file);
|
console.log("File: ", file);
|
||||||
|
@ -3,11 +3,11 @@ import { PdfFile } from '../wrappers/PdfFile.js';
|
|||||||
import { parsePageIndexSpecification } from './common/pageIndexesUtils'
|
import { parsePageIndexSpecification } from './common/pageIndexesUtils'
|
||||||
import { splitPagesByIndex } from './common/splitPagesByIndex.js';
|
import { splitPagesByIndex } from './common/splitPagesByIndex.js';
|
||||||
|
|
||||||
export type SplitPagesParamsType = {
|
export type SplitPdfByIndexParamsType = {
|
||||||
file: PdfFile;
|
file: PdfFile;
|
||||||
pageIndexes: string | number[];
|
pageIndexes: string | number[];
|
||||||
}
|
}
|
||||||
export async function splitPdfByIndex(params: SplitPagesParamsType): Promise<PdfFile[]> {
|
export async function splitPdfByIndex(params: SplitPdfByIndexParamsType): Promise<PdfFile[]> {
|
||||||
const { file, pageIndexes } = params;
|
const { file, pageIndexes } = params;
|
||||||
const pdfLibDocument = await file.pdfLibDocument;
|
const pdfLibDocument = await file.pdfLibDocument;
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@ import { rotatePages, RotateParamsType } from './functions/rotatePages';
|
|||||||
import { scaleContent, ScaleContentParamsType} from './functions/scaleContent';
|
import { scaleContent, ScaleContentParamsType} from './functions/scaleContent';
|
||||||
import { scalePage, ScalePageParamsType } from './functions/scalePage';
|
import { scalePage, ScalePageParamsType } from './functions/scalePage';
|
||||||
import { sortPagesWithPreset, SortPagesWithPresetParamsType } from './functions/sortPagesWithPreset'
|
import { sortPagesWithPreset, SortPagesWithPresetParamsType } from './functions/sortPagesWithPreset'
|
||||||
import { splitOn, SplitOnParamsType } from './functions/splitOn';
|
import { splitPagesByPreset, SplitPageByPresetParamsType } from './functions/splitPagesByPreset';
|
||||||
import { splitPDF, SplitPdfParamsType } from './functions/splitPDF';
|
import { splitPdfByIndex, SplitPdfByIndexParamsType } from './functions/splitPdfByIndex';
|
||||||
import { updateMetadata, UpdateMetadataParams } from "./functions/updateMetadata";
|
import { updateMetadata, UpdateMetadataParams } from "./functions/updateMetadata";
|
||||||
import { PdfFile } from "./wrappers/PdfFile";
|
import { PdfFile } from "./wrappers/PdfFile";
|
||||||
|
|
||||||
@ -25,8 +25,8 @@ const toExport = {
|
|||||||
scaleContent,
|
scaleContent,
|
||||||
scalePage,
|
scalePage,
|
||||||
sortPagesWithPreset,
|
sortPagesWithPreset,
|
||||||
splitOn,
|
splitPagesByPreset,
|
||||||
splitPDF,
|
splitPdfByIndex,
|
||||||
updateMetadata,
|
updateMetadata,
|
||||||
}
|
}
|
||||||
export default toExport;
|
export default toExport;
|
||||||
@ -40,8 +40,8 @@ export type OperationsParametersBaseType = {
|
|||||||
scaleContent: ScaleContentParamsType;
|
scaleContent: ScaleContentParamsType;
|
||||||
scalePage: ScalePageParamsType;
|
scalePage: ScalePageParamsType;
|
||||||
sortPagesWithPreset: SortPagesWithPresetParamsType;
|
sortPagesWithPreset: SortPagesWithPresetParamsType;
|
||||||
splitOn: SplitOnParamsType;
|
splitPagesByPreset: SplitPageByPresetParamsType;
|
||||||
splitPDF: SplitPdfParamsType;
|
splitPdfByIndex: SplitPdfByIndexParamsType;
|
||||||
updateMetadata: UpdateMetadataParams;
|
updateMetadata: UpdateMetadataParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ export async function * traverseOperations(operations: Action[], input: PdfFile[
|
|||||||
case "split":
|
case "split":
|
||||||
// TODO: A split might break the done condition, it may count multiple times. Needs further testing!
|
// TODO: A split might break the done condition, it may count multiple times. Needs further testing!
|
||||||
yield* oneToN(input, action, async (input) => {
|
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++) {
|
for (let j = 0; j < splitResult.length; j++) {
|
||||||
splitResult[j].filename = splitResult[j].filename + "_split" + j;
|
splitResult[j].filename = splitResult[j].filename + "_split" + j;
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ export async function * traverseOperations(operations: Action[], input: PdfFile[
|
|||||||
break;
|
break;
|
||||||
case "splitOn":
|
case "splitOn":
|
||||||
yield* oneToN(input, action, async (input) => {
|
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++) {
|
for (let j = 0; j < splitResult.length; j++) {
|
||||||
splitResult[j].filename = splitResult[j].filename + "_split" + j;
|
splitResult[j].filename = splitResult[j].filename + "_split" + j;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user