mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 19:33:11 +02:00
Add check for ghostscript before plowing on with removeDataOutsideCrop (#5845)
This commit is contained in:
@@ -24,6 +24,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import stirling.software.SPDF.config.EndpointConfiguration;
|
||||||
import stirling.software.SPDF.model.api.general.CropPdfForm;
|
import stirling.software.SPDF.model.api.general.CropPdfForm;
|
||||||
import stirling.software.common.annotations.AutoJobPostMapping;
|
import stirling.software.common.annotations.AutoJobPostMapping;
|
||||||
import stirling.software.common.annotations.api.GeneralApi;
|
import stirling.software.common.annotations.api.GeneralApi;
|
||||||
@@ -118,6 +119,12 @@ public class CropController {
|
|||||||
return r >= threshold && g >= threshold && b >= threshold;
|
return r >= threshold && g >= threshold && b >= threshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final EndpointConfiguration endpointConfiguration;
|
||||||
|
|
||||||
|
private boolean isGhostscriptEnabled() {
|
||||||
|
return endpointConfiguration.isGroupEnabled("Ghostscript");
|
||||||
|
}
|
||||||
|
|
||||||
@AutoJobPostMapping(value = "/crop", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
@AutoJobPostMapping(value = "/crop", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "Crops a PDF document",
|
summary = "Crops a PDF document",
|
||||||
@@ -137,7 +144,7 @@ public class CropController {
|
|||||||
"Crop coordinates (x, y, width, height) are required when auto-crop is not enabled");
|
"Crop coordinates (x, y, width, height) are required when auto-crop is not enabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.isRemoveDataOutsideCrop()) {
|
if (request.isRemoveDataOutsideCrop() && isGhostscriptEnabled()) {
|
||||||
return cropWithGhostscript(request);
|
return cropWithGhostscript(request);
|
||||||
} else {
|
} else {
|
||||||
return cropWithPDFBox(request);
|
return cropWithPDFBox(request);
|
||||||
|
|||||||
Reference in New Issue
Block a user