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
ConstructorsConstructorDescriptionAbstractCsConverter(CsConverterProperties csConverterProperties) Creates anAbstractCsConverter. -
Method Summary
Modifier and TypeMethodDescriptionvoidattemptToConvertTransparencyGroup(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.PdfArrayconvertAnnotationIcArray(com.itextpdf.kernel.pdf.PdfArray icArray) Converts annotation interior color array by using of current color converter.com.itextpdf.kernel.pdf.PdfStreamconvertContentStream(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.PdfImageXObjectconvertImageCs(com.itextpdf.kernel.pdf.xobject.PdfImageXObject imageToConvert, OptimizationSession session) Converts passed image in original color space to image in target color space.protected ListconvertOperatorParameters(List operands) Converts passed operator parameters color space.voidConverts color space of the stored content stream resources.protected ColorDecodercreateColorDecoder(double[] decodeArray) CreatesColorDecoder.protected abstract ColorConverterGetsColorConverterfor 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-CsConverterPropertiesto 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:
-
convertImageCsin 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:
-
convertContentStreamin 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:
-
convertStoredResourcesin 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:
-
convertAnnotationIcArrayin 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:ICsConverterAttempt to converts transparency group dictionary which stored in passed groupEntryHolder PDF object, if this groupEntryHolder can store transparency group by PDF specification.- Specified by:
-
attemptToConvertTransparencyGroupin 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:ICsConverterGets current converter properties instance.- Specified by:
-
getConverterPropertiesin 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
GetsColorConverterfor 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
-