org.apache.fop.pdf

## Class PDFImageXObject

- java.lang.Object
- - org.apache.fop.pdf.PDFObject
  - - org.apache.fop.pdf.AbstractPDFStream
    - - org.apache.fop.pdf.PDFXObject
      - - org.apache.fop.pdf.PDFImageXObject

- All Implemented Interfaces:
    PDFWritable

      public class PDFImageXObject
      extends PDFXObject

  PDF XObject A derivative of the PDF Object, is a PDF Stream that has not only a dictionary but a stream of image data. The dictionary just provides information like the stream length. This outputs the image dictionary and the image data. This is used as a reference for inserting the same image in the document in another place.

- - ### Field Summary

    - ### Fields inherited from class org.apache.fop.pdf.PDFObject

      `log`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PDFImageXObject(int xnumber, PDFImage img)` create an XObject with the given number and name and load the image in the object

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `getChildren(java.util.Set<PDFObject> children)`
    `protected java.lang.String` | `getDefaultFilterName()` Returns the name of a suitable filter for this PDF object.
    `protected int` | `getSizeHint()` Returns a value that hints at the size of the encoded stream.
    `protected boolean` | `multipleFiltersAllowed()` Whether multiple filters can be applied.
    `int` | `output(java.io.OutputStream stream)` Output the image as PDF.
    `protected void` | `outputRawStreamData(java.io.OutputStream out)` Sends the raw stream data to the target OutputStream.
    `protected void` | `populateStreamDict(java.lang.Object lengthEntry)` Populates the dictionary with all necessary entries for the stream.
    `protected void` | `prepareImplicitFilters()` Prepares implicit filters (such as the DCTFilter for JPEG images).

    - ### Methods inherited from class org.apache.fop.pdf.PDFXObject

      `getName`

    - ### Methods inherited from class org.apache.fop.pdf.AbstractPDFStream

      `encodeAndWriteStream, encodeStream, get, getDictionary, getFilterList, outputStreamData, put, registerChildren, setDocument, setupFilterList`

    - ### Methods inherited from class org.apache.fop.pdf.PDFObject

      `contentEquals, encode, encodeBinaryToHexString, encodeString, encodeText, formatObject, getDocument, getDocumentSafely, getGeneration, getObjectID, getObjectNumber, getParent, hasObjectNumber, makeReference, outputInline, referencePDF, setObjectNumber, setObjectNumber, setObjectNumber, setParent, toPDF, toPDFString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PDFImageXObject

          public PDFImageXObject(int xnumber,
                                 PDFImage img)

      create an XObject with the given number and name and load the image in the object
      Parameters:
        `xnumber` - the pdf object X number
        `img` - the pdf image that contains the image data

  - ### Method Detail

    - #### output

          public int output(java.io.OutputStream stream)
                     throws java.io.IOException

      Output the image as PDF. This sets up the image dictionary and adds the image data stream.
      Overrides:
        `output` in class `AbstractPDFStream`
      Parameters:
        `stream` - the output stream to write the data
      Returns:
        the length of the data written
      Throws:
        `java.io.IOException` - if there is an error writing the data

    - #### populateStreamDict

          protected void populateStreamDict(java.lang.Object lengthEntry)

      Populates the dictionary with all necessary entries for the stream. Override this method if you need additional entries.
      Overrides:
        `populateStreamDict` in class `PDFXObject`
      Parameters:
        `lengthEntry` - value for the /Length entry

    - #### outputRawStreamData

          protected void outputRawStreamData(java.io.OutputStream out)
                                      throws java.io.IOException

      Sends the raw stream data to the target OutputStream.
      Specified by:
        `outputRawStreamData` in class `AbstractPDFStream`
      Parameters:
        `out` - OutputStream to write to
      Throws:
        `java.io.IOException` - In case of an I/O problem

    - #### getSizeHint

          protected int getSizeHint()
                             throws java.io.IOException

      Returns a value that hints at the size of the encoded stream. This is used to optimize buffer allocation so fewer buffer reallocations are necessary.
      Overrides:
        `getSizeHint` in class `PDFXObject`
      Returns:
        an estimated size (0 if no hint can be given)
      Throws:
        `java.io.IOException` - in case of an I/O problem

    - #### prepareImplicitFilters

          protected void prepareImplicitFilters()

      Prepares implicit filters (such as the DCTFilter for JPEG images). You must make sure that the appropriate filters are in the filter list at the right places.
      Overrides:
        `prepareImplicitFilters` in class `AbstractPDFStream`

    - #### getDefaultFilterName

          protected java.lang.String getDefaultFilterName()

      Returns the name of a suitable filter for this PDF object. This class uses the PDFImage instance to determine the default filter.
      Overrides:
        `getDefaultFilterName` in class `AbstractPDFStream`
      Returns:
        the default filter
      See Also:
        `PDFFilterList`

    - #### multipleFiltersAllowed

          protected boolean multipleFiltersAllowed()

      Whether multiple filters can be applied.
      Overrides:
        `multipleFiltersAllowed` in class `AbstractPDFStream`
      Returns:
        true if multiple filters allowed

    - #### getChildren

          public void getChildren(java.util.Set<PDFObject> children)

      Overrides:
        `getChildren` in class `AbstractPDFStream`

Copyright 1999-2020 The Apache Software Foundation. All Rights Reserved.