Class AbstractCsConverter
java.lang.Object
com.itextpdf.pdfoptimizer.handlers.converters.AbstractCsConverter
- All Implemented Interfaces:
-
ICsConverter
- Direct Known Subclasses:
-
CmykToRgbCsConverter
,RgbToCmykCsConverter
This is the abstract class for color space converters which are used to convert PDF objects in the original color space to PDF objects in target color space.
-
Constructor Summary
ConstructorDescriptionAbstractCsConverter
(CsConverterProperties csConverterProperties) Creates anAbstractCsConverter
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
attemptToConvertTransparencyGroup
(com.itextpdf.kernel.pdf.PdfObject groupEntryHolder, OptimizationSession session) Attempt to converts transparency group dictionary which stored in passed groupEntryHolder PDF object, if this groupEntryHolder can store transparency group by PDF specification.com.itextpdf.kernel.pdf.PdfArray
convertAnnotationIcArray
(com.itextpdf.kernel.pdf.PdfArray icArray) Converts annotation interior color array by using of current color converter.com.itextpdf.kernel.pdf.PdfStream
convertContentStream
(com.itextpdf.kernel.pdf.PdfStream stream, com.itextpdf.kernel.pdf.PdfResources externalResources, OptimizationSession session) Converts color space of the passed content stream.com.itextpdf.kernel.pdf.xobject.PdfImageXObject
convertImageCs
(com.itextpdf.kernel.pdf.xobject.PdfImageXObject imageToConvert, OptimizationSession session) Converts passed image in original color space to image in target color space.protected List
convertOperatorParameters
(List operands) Converts passed operator parameters color space.void
Converts color space of the stored content stream resources.protected ColorDecoder
createColorDecoder
(double[] decodeArray) CreatesColorDecoder
.protected abstract ColorConverter
GetsColorConverter
for appropriate convertion.Gets current converter properties instance.protected abstract Class extends com.itextpdf.kernel.pdf.colorspace.PdfColorSpace>
Gets original color space class.
-
Constructor Details
-
AbstractCsConverter
Creates anAbstractCsConverter
.- Parameters:
-
csConverterProperties
-CsConverterProperties
to be used by thisAbstractCsConverter
-
-
Method Details
-
convertImageCs
public com.itextpdf.kernel.pdf.xobject.PdfImageXObject convertImageCs(com.itextpdf.kernel.pdf.xobject.PdfImageXObject imageToConvert, OptimizationSession session) Converts passed image in original color space to image in target color space.- Specified by:
-
convertImageCs
in interfaceICsConverter
- Parameters:
-
imageToConvert
- the image in original color space -
session
- is an auxiliary object used to support share data between stages of optimization process - Returns:
- the image in target color space if converting can be performed and the same instance otherwise
-
convertContentStream
public com.itextpdf.kernel.pdf.PdfStream convertContentStream(com.itextpdf.kernel.pdf.PdfStream stream, com.itextpdf.kernel.pdf.PdfResources externalResources, OptimizationSession session) Converts color space of the passed content stream. Note that this method does not process content stream resources and passed external resources. Also, this method saves resources for their subsequent processing within theconvertStoredResources(OptimizationSession)
method.- Specified by:
-
convertContentStream
in interfaceICsConverter
- Parameters:
-
stream
- the PDF content stream instance for conversion -
externalResources
- the external content stream resources. Used in the case when the page content stream is converted, and the resources are stored not in the content stream but in the page dictionary. In other case should be null -
session
- is an auxiliary object used to support share data between stages of optimization process - Returns:
- the content stream with converted color space if converting can be performed and the same instance otherwise
-
convertStoredResources
Converts color space of the stored content stream resources. Resource stored takes place within theconvertContentStream(PdfStream, PdfResources, OptimizationSession)
method. Note that this method should be called after all content streams have been processed.- Specified by:
-
convertStoredResources
in interfaceICsConverter
- Parameters:
-
session
- is an auxiliary object used to support share data between stages of optimization process
-
convertAnnotationIcArray
public com.itextpdf.kernel.pdf.PdfArray convertAnnotationIcArray(com.itextpdf.kernel.pdf.PdfArray icArray) Converts annotation interior color array by using of current color converter.- Specified by:
-
convertAnnotationIcArray
in interfaceICsConverter
- Parameters:
-
icArray
- the interior color array - Returns:
- the converted interior color array if converting can be performed and the same instance otherwise
-
attemptToConvertTransparencyGroup
public void attemptToConvertTransparencyGroup(com.itextpdf.kernel.pdf.PdfObject groupEntryHolder, OptimizationSession session) Description copied from interface:ICsConverter
Attempt to converts transparency group dictionary which stored in passed groupEntryHolder PDF object, if this groupEntryHolder can store transparency group by PDF specification.- Specified by:
-
attemptToConvertTransparencyGroup
in interfaceICsConverter
- Parameters:
-
groupEntryHolder
- the PDF object which stored transparency group dictionary to convert -
session
- is an auxiliary object used to support share data between stages of optimization process
-
getConverterProperties
Description copied from interface:ICsConverter
Gets current converter properties instance.- Specified by:
-
getConverterProperties
in interfaceICsConverter
- Returns:
- the converter properties instance
-
getOriginalCsClass
protected abstract Class extends com.itextpdf.kernel.pdf.colorspace.PdfColorSpace> getOriginalCsClass()Gets original color space class. The result of this method is used to check that passed PDF object has a necessary color space.- Returns:
- the original color space class
-
getColorConverter
GetsColorConverter
for appropriate convertion. The result of this method is used for conversion and for filling necessary fields in converted PDF object.- Returns:
- the target color space name
-
createColorDecoder
CreatesColorDecoder
. Shall be overriden by a subclass to support decode array in image conversion.- Parameters:
-
decodeArray
- decode array in image stream - Returns:
-
ColorDecoder
-
convertOperatorParameters
Converts passed operator parameters color space.- Parameters:
-
operands
- the operator with operator parameters - Returns:
- the converted operator parameters without parameter
-