org.apache.fop.pdf

## Interface PDFImage

- All Known Implementing Classes:
    AbstractImageAdapter, AlphaRasterImage, BitmapImage, ImageRawCCITTFaxAdapter, ImageRawJPEGAdapter, ImageRawPNGAdapter, ImageRenderedAdapter

      public interface PDFImage

  Interface for a PDF image. This is used for inserting an image into PDF.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getBitsPerComponent()` Get the bits per color component for this image.
    `PDFDeviceColorSpace` | `getColorSpace()` Get the color space for this image.
    `String` | `getFilterHint()` Returns a hint in form of a String (Possible values from PDFFilterList) indicating which filter setup should be used to encode the object.
    `int` | `getHeight()` Get the image height in pixels.
    `PDFICCStream` | `getICCStream()` Get the ICC stream for this image.
    `String` | `getKey()` Key to look up XObject.
    `String` | `getMask()` Get the PDF reference for a bitmap mask.
    `PDFFilter` | `getPDFFilter()` Get the PDF Filter to be applied to the image.
    `PDFReference` | `getSoftMaskReference()` Get the PDF reference for a soft mask.
    `PDFColor` | `getTransparentColor()` Get the transparent color.
    `int` | `getWidth()` Get the image width in pixels.
    `boolean` | `isInverted()`
    `boolean` | `isPS()` Check if this image is a PostScript image.
    `boolean` | `isTransparent()` Check if this image has a transparent color transparency.
    `boolean` | `multipleFiltersAllowed()` Indicates whether multiple image filters are allowed; this is implemented because Adobe Reader does not like multiple FlateDecode filters applied to an image even though that allowed by the PDF spec; this is probable due to security concerns since many PDF malware exploits, like zip bombs, make use of a chain of FlateDecode filters.
    `void` | `outputContents(OutputStream out)` Writes the raw, unencoded contents of the image to a given output stream.
    `void` | `populateXObjectDictionary(PDFDictionary dict)` Populates the XObject's dictionary with additional values.
    `void` | `setup(PDFDocument doc)` Setup the PDF image for the current document.

- - ### Method Detail

    - #### getKey

          String getKey()

      Key to look up XObject. This should be a unique key to refer to the image.
      Returns:
        the key for this image

    - #### setup

          void setup(PDFDocument doc)

      Setup the PDF image for the current document. Some image formats may need to access the document (for example to add an ICC profile to the document).
      Parameters:
        `doc` - the PDF parent document (todo) Remove this and delegate to the XObject

    - #### getWidth

          int getWidth()

      Get the image width in pixels.
      Returns:
        the image width

    - #### getHeight

          int getHeight()

      Get the image height in pixels.
      Returns:
        the image height

    - #### getColorSpace

          PDFDeviceColorSpace getColorSpace()

      Get the color space for this image. Possible results are: DeviceGray, DeviceRGB, or DeviceCMYK
      Returns:
        the color space

    - #### getBitsPerComponent

          int getBitsPerComponent()

      Get the bits per color component for this image.
      Returns:
        the bits per component

    - #### isPS

          boolean isPS()

      Check if this image is a PostScript image.
      Returns:
        true if this is a PostScript image

    - #### isTransparent

          boolean isTransparent()

      Check if this image has a transparent color transparency. Classes such as `PDFImageXObject` rely on this simple binary model of transparency (e.g. compare to `Transparency`) in order to render color key masking (see PDF Spec 1.7 Chapter 8.9.6.4). Therefore only return true if image has fully transparent colors.
      Returns:
        true if it has at least one fully transparent color

    - #### getTransparentColor

          PDFColor getTransparentColor()

      Get the transparent color.
      Returns:
        the transparent color for this image

    - #### getMask

          String getMask()

      Get the PDF reference for a bitmap mask.
      Returns:
        the PDF reference for the mask image

    - #### getSoftMaskReference

          PDFReference getSoftMaskReference()

      Get the PDF reference for a soft mask.
      Returns:
        the PDF reference for a soft mask image (or null if there's no soft mask)

    - #### isInverted

          boolean isInverted()

      Returns:
        true for CMYK images generated by Adobe Photoshop

    - #### getPDFFilter

          PDFFilter getPDFFilter()

      Get the PDF Filter to be applied to the image.
      Returns:
        the PDF Filter or null

    - #### outputContents

          void outputContents(OutputStream out)
                       throws IOException

      Writes the raw, unencoded contents of the image to a given output stream.
      Parameters:
        `out` - OutputStream to write to
      Throws:
        `IOException` - if there creating stream

    - #### populateXObjectDictionary

          void populateXObjectDictionary(PDFDictionary dict)

      Populates the XObject's dictionary with additional values. The values are added to the dictionary after all the values obtained from other methods from this interface have been put into the dictionary. That allows to override certain values.
      Parameters:
        `dict` - the dictionary to fill

    - #### getICCStream

          PDFICCStream getICCStream()

      Get the ICC stream for this image.
      Returns:
        the ICC stream for this image if any

    - #### getFilterHint

          String getFilterHint()

      Returns a hint in form of a String (Possible values from PDFFilterList) indicating which filter setup should be used to encode the object.
      Returns:
        the filter setup hint

    - #### multipleFiltersAllowed

          boolean multipleFiltersAllowed()

      Indicates whether multiple image filters are allowed; this is implemented because Adobe Reader does not like multiple FlateDecode filters applied to an image even though that allowed by the PDF spec; this is probable due to security concerns since many PDF malware exploits, like zip bombs, make use of a chain of FlateDecode filters.

Copyright © 2025 Apache Software Foundation. All rights reserved.