Skip to content

Commit 2153d4e

Browse files
author
glenn.volckaert
committed
Add support for function execution
Add support for extraction of images with a separation color space DEVSIX-3538
1 parent b81d187 commit 2153d4e

40 files changed

+4321
-102
lines changed

kernel/src/main/java/com/itextpdf/kernel/exceptions/KernelExceptionMessageConstant.java

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,46 @@ public final class KernelExceptionMessageConstant {
202202
public static final String INVALID_CROSS_REFERENCE_ENTRY_IN_THIS_XREF_SUBSECTION = "Invalid cross reference entry "
203203
+ "in this xref subsection.";
204204
public static final String INVALID_INDIRECT_REFERENCE = "Invalid indirect reference {0}.";
205+
206+
public static final String INVALID_INPUT_FOR_TYPE_2_FUNCTION =
207+
"Invalid input value for PDF Type 2 Function, value should be a single number.";
208+
public static final String INVALID_INPUT_FOR_TYPE_3_FUNCTION =
209+
"Invalid input value for PDF Type 3 Function, value should be a single number.";
205210
public static final String INVALID_MEDIA_BOX_VALUE = "Tne media box object has incorrect values.";
206211
public static final String INVALID_PAGE_STRUCTURE = "Invalid page structure {0}.";
207212
public static final String INVALID_PAGE_STRUCTURE_PAGES_MUST_BE_PDF_DICTIONARY = "Invalid page structure. /Pages "
208213
+ "must be PdfDictionary.";
214+
public static final String INVALID_TYPE_2_FUNCTION_DOMAIN =
215+
"Invalid PDF Type 2 Function object, \"Domain\" array shall consist of 2 numbers.";
216+
public static final String INVALID_TYPE_2_FUNCTION_N =
217+
"Invalid PDF Type 2 Function object, \"N\" field should be existed and must be a number.";
218+
public static final String INVALID_TYPE_2_FUNCTION_N_NEGATIVE =
219+
"Invalid PDF Type 2 Function object, when \"N\" is negative, values of \"Domain\" shall "
220+
+ "not allow zero as input value.";
221+
public static final String INVALID_TYPE_2_FUNCTION_N_NOT_INTEGER =
222+
"Invalid PDF Type 2 Function object, when \"N\" is not an integer, values of \"Domain\" shall "
223+
+ "define the input value as non-negative.";
224+
public static final String INVALID_TYPE_2_FUNCTION_OUTPUT_SIZE =
225+
"Invalid PDF Type 2 Function object, if present the size of \"C0\", \"C1\" and half "
226+
+ "\"Range\" shall be equal.";
227+
public static final String INVALID_TYPE_3_FUNCTION_BOUNDS =
228+
"Invalid PDF Type 3 Function object, \"Bounds\" elements shall be in order of increasing value, and "
229+
+ "each value shall be within the domain defined by \"Domain\".";
230+
public static final String INVALID_TYPE_3_FUNCTION_DOMAIN =
231+
"Invalid PDF Type 3 Function object, \"Domain\" array shall consist of 2 numbers.";
232+
public static final String INVALID_TYPE_3_FUNCTION_FUNCTIONS_OUTPUT =
233+
"Invalid PDF Type 3 Function object, the output dimensionality of all functions shall be the same, "
234+
+ "and compatible with the value of \"Range\".";
235+
public static final String INVALID_TYPE_3_FUNCTION_FUNCTIONS_INPUT =
236+
"Invalid PDF Type 3 Function object, all functions shall have 1 input value.";
237+
public static final String INVALID_TYPE_3_FUNCTION_NULL_BOUNDS =
238+
"Invalid PDF Type 3 Function object, \"Bounds\" array should be exist and it size should corresponds "
239+
+ "to the size of \"Functions\" array.";
240+
public static final String INVALID_TYPE_3_FUNCTION_NULL_ENCODE =
241+
"Invalid PDF Type 3 Function object, \"Encode\" array should be exist and it size should be 2 times "
242+
+ "more than \"Functions\" array size.";
243+
public static final String INVALID_TYPE_3_FUNCTION_NULL_FUNCTIONS =
244+
"Invalid PDF Type 3 Function object, \"Functions\" array should be exist and can't be empty.";
209245
public static final String INVALID_RANGE_ARRAY = "Invalid range array.";
210246
public static final String INVALID_OFFSET_FOR_THIS_OBJECT = "Invalid offset for object {0}.";
211247
public static final String INVALID_XREF_STREAM = "Invalid xref stream.";
@@ -355,6 +391,30 @@ public final class KernelExceptionMessageConstant {
355391
+ "boolean for this collection sort dictionary.";
356392
public static final String QUAD_POINT_ARRAY_LENGTH_IS_NOT_A_MULTIPLE_OF_EIGHT = "The QuadPoint Array length is "
357393
+ "not a multiple of 8.";
394+
public static final String FUNCTION_NOT_SET = "The output size depends on the functions, but no function is"
395+
+ " set yet.";
396+
public static final String INVALID_LENGTH = "The offset + length must be lower than or equal to the length of "
397+
+ "the byte array.";
398+
public static final String INVALID_LENGTH_FOR_WORDSIZE = "The length must be a multiple of {0}.";
399+
public static final String TYPE4_EXECUTION_NOT_SUPPORTED =
400+
"Type 4 functions are not yet supported for separation color image extraction.";
401+
public static final String GET_IMAGEBYTES_FOR_SEPARATION_COLOR_ONLY_SUPPORTS_RGB =
402+
"Only RGB alternate color spaces are currently supported for extracting separation color images";
403+
public static final String INPUT_NOT_MULTIPLE_OF_DOMAIN_SIZE = "The size of the input array must be a multiple of "
404+
+ "the domain size";
405+
public static final String INPUT_NOT_MULTIPLE_OF_RANGE_SIZE = "The size of the input array must be a multiple of "
406+
+ "the range size";
407+
408+
public static final String PDF_TYPE0_FUNCTION_NOT_NULL_PARAMETERS = "Domain, range and size must be not null";
409+
public static final String PDF_TYPE0_FUNCTION_INVALID_ORDER = "Order must be equal to 1 or 3";
410+
public static final String PDF_TYPE0_FUNCTION_INVALID_DOMAIN = "Invalid domain for PDF function of type 0";
411+
public static final String PDF_TYPE0_FUNCTION_INVALID_RANGE = "Invalid encode array for PDF function of type 0";
412+
public static final String PDF_TYPE0_FUNCTION_INVALID_SIZE = "Invalid size array for PDF function of type 0";
413+
public static final String PDF_TYPE0_FUNCTION_INVALID_ENCODE = "Invalid encode array for PDF function of type 0";
414+
public static final String PDF_TYPE0_FUNCTION_INVALID_DECODE = "Invalid decode array for PDF function of type 0";
415+
public static final String PDF_TYPE0_FUNCTION_INVALID_SAMPLES = "Invalid samples array for PDF function of type 0";
416+
public static final String PDF_TYPE0_FUNCTION_BITS_PER_SAMPLE_INVALID_VALUE =
417+
"bitsPerSample value must be from {1, 2, 4, 8, 12, 16, 24, 32}";
358418

359419
private KernelExceptionMessageConstant(){}
360420
}

kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/PdfSpecialCs.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ This file is part of the iText (R) project.
5252
import com.itextpdf.kernel.pdf.PdfNumber;
5353
import com.itextpdf.kernel.pdf.PdfObject;
5454
import com.itextpdf.kernel.pdf.PdfString;
55+
import com.itextpdf.kernel.pdf.function.PdfFunctionFactory;
56+
import com.itextpdf.kernel.pdf.function.IPdfFunction;
5557
import com.itextpdf.kernel.pdf.function.PdfFunction;
5658

5759
import java.util.Arrays;
@@ -144,6 +146,15 @@ public PdfName getName() {
144146
return ((PdfArray)getPdfObject()).getAsName(1);
145147
}
146148

149+
/**
150+
* Gets the function to calulate a separation color value to an alternative colorspace.
151+
*
152+
* @return a {@link IPdfFunction} to perform the calculation
153+
*/
154+
public IPdfFunction getTintTransformation() {
155+
return PdfFunctionFactory.create(((PdfArray)getPdfObject()).get(3));
156+
}
157+
147158
private static PdfArray getSeparationCsArray(PdfName name, PdfObject alternateSpace, PdfObject tintTransform) {
148159
PdfArray separation = new PdfArray();
149160
separation.add(PdfName.Separation);

0 commit comments

Comments
 (0)