org.apache.fop.pdf

## Class PDFFormXObject

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

- All Implemented Interfaces:
    PDFWritable

      public class PDFFormXObject
      extends PDFXObject

  PDF Form XObject A derivative of the PDFXObject, is a PDF Stream that has not only a dictionary but a stream of image data.

- - ### Field Summary

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

      `log`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PDFFormXObject(int xnumber, PDFStream contents, PDFReference resources)` create a FormXObject 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
    --- | ---
    `Rectangle2D` | `getBBox()` Returns the bounding box.
    `AffineTransform` | `getMatrix()` Returns the Matrix value.
    `int` | `output(OutputStream stream)` Overload the base object method so we don't have to copy byte arrays around so much Write the PDF represention of this object
    `protected void` | `outputRawStreamData(OutputStream out)` Sends the raw stream data to the target OutputStream.
    `protected void` | `populateStreamDict(Object lengthEntry)` Populates the dictionary with all necessary entries for the stream.
    `void` | `setBBox(Rectangle2D bbox)` Sets the bounding box of the Form XObject.
    `void` | `setData(byte[] data)` Used to set the contents of the PDF stream.
    `void` | `setMatrix(AffineTransform at)` Sets the Matrix value

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

      `getName, getSizeHint`

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

      `encodeAndWriteStream, encodeStream, get, getChildren, getDefaultFilterName, getDictionary, getFilterList, multipleFiltersAllowed, outputStreamData, prepareImplicitFilters, put, registerChildren, setDocument, setupFilterList, supportsObjectStream`

    - ### 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

    - #### PDFFormXObject

          public PDFFormXObject(int xnumber,
                                PDFStream contents,
                                PDFReference resources)

      create a FormXObject with the given number and name and load the image in the object
      Parameters:
        `xnumber` - the pdf object X number
        `contents` - the form's contents
        `resources` - the resource PDF reference

  - ### Method Detail

    - #### setBBox

          public void setBBox(Rectangle2D bbox)

      Sets the bounding box of the Form XObject.
      Parameters:
        `bbox` - the bounding box

    - #### getBBox

          public Rectangle2D getBBox()

      Returns the bounding box.
      Returns:
        the BBox value

    - #### setMatrix

          public void setMatrix(AffineTransform at)

      Sets the Matrix value
      Parameters:
        `at` - the AffineTransform defining the transformation matrix

    - #### getMatrix

          public AffineTransform getMatrix()

      Returns the Matrix value.
      Returns:
        the Matrix

    - #### setData

          public void setData(byte[] data)
                       throws IOException

      Used to set the contents of the PDF stream.
      Parameters:
        `data` - the contents as a byte array
      Throws:
        `IOException` - in case of an I/O problem

    - #### outputRawStreamData

          protected void outputRawStreamData(OutputStream out)
                                      throws IOException

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

    - #### output

          public int output(OutputStream stream)
                     throws IOException

      Overload the base object method so we don't have to copy byte arrays around so much Write the PDF represention of this object
      Overrides:
        `output` in class `AbstractPDFStream`
      Parameters:
        `stream` - the stream to write the PDF to
      Returns:
        the number of bytes written
      Throws:
        `IOException` - if there is an error writing to the stream

    - #### populateStreamDict

          protected void populateStreamDict(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

Copyright © 2025 Apache Software Foundation. All rights reserved.