mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2026-03-04 02:20:19 +01:00
feat(replace-and-invert-colour): Add CMYK color space conversion with prepress preset for PDF processing (#4494)
This commit is contained in:
@@ -5,6 +5,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import stirling.software.common.model.api.misc.HighContrastColorCombination;
|
||||
import stirling.software.common.model.api.misc.ReplaceAndInvert;
|
||||
import stirling.software.common.util.misc.ColorSpaceConversionStrategy;
|
||||
import stirling.software.common.util.misc.CustomColorReplaceStrategy;
|
||||
import stirling.software.common.util.misc.InvertFullColorStrategy;
|
||||
import stirling.software.common.util.misc.ReplaceAndInvertColorStrategy;
|
||||
@@ -19,21 +20,17 @@ public class ReplaceAndInvertColorFactory {
|
||||
String backGroundColor,
|
||||
String textColor) {
|
||||
|
||||
if (replaceAndInvertOption == ReplaceAndInvert.CUSTOM_COLOR
|
||||
|| replaceAndInvertOption == ReplaceAndInvert.HIGH_CONTRAST_COLOR) {
|
||||
|
||||
return new CustomColorReplaceStrategy(
|
||||
file,
|
||||
replaceAndInvertOption,
|
||||
textColor,
|
||||
backGroundColor,
|
||||
highContrastColorCombination);
|
||||
|
||||
} else if (replaceAndInvertOption == ReplaceAndInvert.FULL_INVERSION) {
|
||||
|
||||
return new InvertFullColorStrategy(file, replaceAndInvertOption);
|
||||
}
|
||||
|
||||
return null;
|
||||
return switch (replaceAndInvertOption) {
|
||||
case CUSTOM_COLOR, HIGH_CONTRAST_COLOR ->
|
||||
new CustomColorReplaceStrategy(
|
||||
file,
|
||||
replaceAndInvertOption,
|
||||
textColor,
|
||||
backGroundColor,
|
||||
highContrastColorCombination);
|
||||
case FULL_INVERSION -> new InvertFullColorStrategy(file, replaceAndInvertOption);
|
||||
case COLOR_SPACE_CONVERSION ->
|
||||
new ColorSpaceConversionStrategy(file, replaceAndInvertOption);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -400,6 +400,7 @@ public class EndpointConfiguration {
|
||||
/* Ghostscript */
|
||||
addEndpointToGroup("Ghostscript", "repair");
|
||||
addEndpointToGroup("Ghostscript", "compress-pdf");
|
||||
addEndpointToGroup("Ghostscript", "replace-invert-pdf");
|
||||
|
||||
/* tesseract */
|
||||
addEndpointToGroup("tesseract", "ocr-pdf");
|
||||
|
||||
@@ -31,8 +31,8 @@ public class ReplaceAndInvertColorController {
|
||||
@Operation(
|
||||
summary = "Replace-Invert Color PDF",
|
||||
description =
|
||||
"This endpoint accepts a PDF file and option of invert all colors or replace"
|
||||
+ " text and background colors. Input:PDF Output:PDF Type:SISO")
|
||||
"This endpoint accepts a PDF file and provides options to invert all colors, replace"
|
||||
+ " text and background colors, or convert to CMYK color space for printing. Input:PDF Output:PDF Type:SISO")
|
||||
public ResponseEntity<InputStreamResource> replaceAndInvertColor(
|
||||
@ModelAttribute ReplaceAndInvertColorRequest request) throws IOException {
|
||||
|
||||
|
||||
@@ -17,7 +17,12 @@ public class ReplaceAndInvertColorRequest extends PDFFile {
|
||||
description = "Replace and Invert color options of a pdf.",
|
||||
requiredMode = Schema.RequiredMode.REQUIRED,
|
||||
defaultValue = "HIGH_CONTRAST_COLOR",
|
||||
allowableValues = {"HIGH_CONTRAST_COLOR", "CUSTOM_COLOR", "FULL_INVERSION"})
|
||||
allowableValues = {
|
||||
"HIGH_CONTRAST_COLOR",
|
||||
"CUSTOM_COLOR",
|
||||
"FULL_INVERSION",
|
||||
"COLOR_SPACE_CONVERSION"
|
||||
})
|
||||
private ReplaceAndInvert replaceAndInvertOption;
|
||||
|
||||
@Schema(
|
||||
|
||||
@@ -878,6 +878,12 @@ replace-color.selectText.8=Yellow text on black background
|
||||
replace-color.selectText.9=Green text on black background
|
||||
replace-color.selectText.10=Choose text Colour
|
||||
replace-color.selectText.11=Choose background Colour
|
||||
replace-color.selectText.12=Colour Space Conversion (CMYK for Printing)
|
||||
replace-color.selectText.13=CMYK Colour Space Conversion
|
||||
replace-color.selectText.14=This option converts the PDF from RGB colour space to CMYK colour space, which is optimized for professional printing. This process:
|
||||
replace-color.selectText.15=Converts colours to CMYK (Cyan, Magenta, Yellow, Black) colour model used by professional printers
|
||||
replace-color.selectText.16=Optimizes the PDF for print production with prepress settings
|
||||
replace-color.selectText.17=May result in slight colour changes as CMYK has a smaller colour gamut than RGB
|
||||
replace-color.submit=Replace
|
||||
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
<option value="HIGH_CONTRAST_COLOR" th:text="#{replace-color.selectText.2}" ></option>
|
||||
<option value="CUSTOM_COLOR" th:text="#{replace-color.selectText.3}"></option>
|
||||
<option value="FULL_INVERSION" th:text="#{replace-color.selectText.4}" selected></option>
|
||||
<option th:text="#{replace-color.selectText.12}" value="COLOR_SPACE_CONVERSION"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@@ -56,6 +57,18 @@
|
||||
<input type="color" name="backGroundColor" id="bg-color" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mb-3" id="color-space-info" style="display: none">
|
||||
<div class="card-body">
|
||||
<h4 th:text="#{replace-color.selectText.13}"></h4>
|
||||
<p th:text="#{replace-color.selectText.14}"></p>
|
||||
<ul>
|
||||
<li th:text="#{replace-color.selectText.15}"></li>
|
||||
<li th:text="#{replace-color.selectText.16}"></li>
|
||||
<li th:text="#{replace-color.selectText.17}"></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{replace-color.submit}"></button>
|
||||
</form>
|
||||
@@ -74,12 +87,15 @@
|
||||
$('#high-contrast-options').hide();
|
||||
$('#custom-color-1').hide();
|
||||
$('#custom-color-2').hide();
|
||||
$('#color-space-info').hide();
|
||||
|
||||
if (selectedOption === "HIGH_CONTRAST_COLOR") {
|
||||
$('#high-contrast-options').show();
|
||||
} else if (selectedOption === "CUSTOM_COLOR") {
|
||||
$('#custom-color-1').show();
|
||||
$('#custom-color-2').show();
|
||||
} else if (selectedOption === "COLOR_SPACE_CONVERSION") {
|
||||
$('#color-space-info').show();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user