mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-15 19:10:47 +02:00
feat: split pdf into small chunks by pdfbox (#5718)
Co-authored-by: Ubuntu <[email protected]> Co-authored-by: Anthony Stirling <[email protected]>
This commit is contained in:
co-authored by
Ubuntu
Anthony Stirling
parent
73213901d1
commit
9b0610b2cc
@@ -45,6 +45,12 @@ export const buildSplitFormData = (parameters: SplitParameters, file: File): For
|
||||
case SPLIT_METHODS.BY_PAGE_DIVIDER:
|
||||
formData.append("duplexMode", (parameters.duplexMode ?? false).toString());
|
||||
break;
|
||||
case SPLIT_METHODS.BY_POSTER:
|
||||
formData.append("pageSize", parameters.pageSize || 'A4');
|
||||
formData.append("xFactor", parameters.xFactor || '2');
|
||||
formData.append("yFactor", parameters.yFactor || '2');
|
||||
formData.append("rightToLeft", (parameters.rightToLeft ?? false).toString());
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unknown split method: ${parameters.method}`);
|
||||
}
|
||||
@@ -66,6 +72,8 @@ export const getSplitEndpoint = (parameters: SplitParameters): string => {
|
||||
return "/api/v1/general/split-pdf-by-chapters";
|
||||
case SPLIT_METHODS.BY_PAGE_DIVIDER:
|
||||
return "/api/v1/misc/auto-split-pdf";
|
||||
case SPLIT_METHODS.BY_POSTER:
|
||||
return "/api/v1/general/split-for-poster-print";
|
||||
default:
|
||||
throw new Error(`Unknown split method: ${parameters.method}`);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,10 @@ export interface SplitParameters extends BaseParameters {
|
||||
duplexMode: boolean;
|
||||
splitMode?: string;
|
||||
customPages?: string;
|
||||
pageSize?: string;
|
||||
xFactor?: string;
|
||||
yFactor?: string;
|
||||
rightToLeft?: boolean;
|
||||
}
|
||||
|
||||
export type SplitParametersHook = BaseParametersHook<SplitParameters>;
|
||||
@@ -32,6 +36,10 @@ export const defaultParameters: SplitParameters = {
|
||||
duplexMode: false,
|
||||
splitMode: 'SPLIT_ALL',
|
||||
customPages: '',
|
||||
pageSize: 'A4',
|
||||
xFactor: '2',
|
||||
yFactor: '2',
|
||||
rightToLeft: false,
|
||||
};
|
||||
|
||||
export const useSplitParameters = (): SplitParametersHook => {
|
||||
@@ -61,6 +69,8 @@ export const useSplitParameters = (): SplitParametersHook => {
|
||||
return params.bookmarkLevel !== "";
|
||||
case SPLIT_METHODS.BY_PAGE_DIVIDER:
|
||||
return true; // No required parameters
|
||||
case SPLIT_METHODS.BY_POSTER:
|
||||
return params.pageSize !== "" && params.xFactor !== "" && params.yFactor !== "";
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user