mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 11:23:10 +02:00
V2 Tool - Auto split (#4446)
integrated auto split, with flattened split tool --------- Co-authored-by: Connor Yoh <[email protected]>
This commit is contained in:
@@ -38,6 +38,9 @@ export const buildSplitFormData = (parameters: SplitParameters, file: File): For
|
||||
formData.append("includeMetadata", parameters.includeMetadata.toString());
|
||||
formData.append("allowDuplicates", parameters.allowDuplicates.toString());
|
||||
break;
|
||||
case SPLIT_METHODS.BY_PAGE_DIVIDER:
|
||||
formData.append("duplexMode", parameters.duplexMode.toString());
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unknown split method: ${parameters.method}`);
|
||||
}
|
||||
@@ -57,6 +60,8 @@ export const getSplitEndpoint = (parameters: SplitParameters): string => {
|
||||
return "/api/v1/general/split-by-size-or-count";
|
||||
case SPLIT_METHODS.BY_CHAPTERS:
|
||||
return "/api/v1/general/split-pdf-by-chapters";
|
||||
case SPLIT_METHODS.BY_PAGE_DIVIDER:
|
||||
return "/api/v1/misc/auto-split-pdf";
|
||||
default:
|
||||
throw new Error(`Unknown split method: ${parameters.method}`);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ export interface SplitParameters extends BaseParameters {
|
||||
bookmarkLevel: string;
|
||||
includeMetadata: boolean;
|
||||
allowDuplicates: boolean;
|
||||
duplexMode: boolean;
|
||||
}
|
||||
|
||||
export type SplitParametersHook = BaseParametersHook<SplitParameters>;
|
||||
@@ -26,6 +27,7 @@ export const defaultParameters: SplitParameters = {
|
||||
bookmarkLevel: '1',
|
||||
includeMetadata: false,
|
||||
allowDuplicates: false,
|
||||
duplexMode: false,
|
||||
};
|
||||
|
||||
export const useSplitParameters = (): SplitParametersHook => {
|
||||
@@ -49,6 +51,8 @@ export const useSplitParameters = (): SplitParametersHook => {
|
||||
return params.splitValue.trim() !== "";
|
||||
case SPLIT_METHODS.BY_CHAPTERS:
|
||||
return params.bookmarkLevel !== "";
|
||||
case SPLIT_METHODS.BY_PAGE_DIVIDER:
|
||||
return true; // No required parameters
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user