Class AbstractCsConverter

java.lang.Object
com.itextpdf.pdfoptimizer.handlers.converters.AbstractCsConverter
All Implemented Interfaces:
ICsConverter
Direct Known Subclasses:
CmykToRgbCsConverter, RgbToCmykCsConverter

public abstract class AbstractCsConverter extends Object implements ICsConverter
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 Details

  • 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 interface ICsConverter
      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 the convertStoredResources(OptimizationSession) method.
      Specified by:
      convertContentStream in interface ICsConverter
      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

      public void convertStoredResources (OptimizationSession session)
      Converts color space of the stored content stream resources. Resource stored takes place within the convertContentStream(PdfStream, PdfResources, OptimizationSession) method. Note that this method should be called after all content streams have been processed.
      Specified by:
      convertStoredResources in interface ICsConverter
      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 interface ICsConverter
      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 interface ICsConverter
      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

      public CsConverterProperties getConverterProperties()
      Description copied from interface: ICsConverter
      Gets current converter properties instance.
      Specified by:
      getConverterProperties in interface ICsConverter
      Returns:
      the converter properties instance
    • getOriginalCsClass

      protected abstract Class 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

      protected abstract ColorConverter getColorConverter()
      Gets ColorConverter 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

      protected ColorDecoder createColorDecoder (double[] decodeArray)
      Creates ColorDecoder. Shall be overriden by a subclass to support decode array in image conversion.
      Parameters:
      decodeArray - decode array in image stream
      Returns:
      ColorDecoder
    • convertOperatorParameters

      protected List convertOperatorParameters (List operands)
      Converts passed operator parameters color space.
      Parameters:
      operands - the operator with operator parameters
      Returns:
      the converted operator parameters without parameter