org.apache.pdfbox.pdmodel.graphics

## Class PDXObject

- java.lang.Object
- - org.apache.pdfbox.pdmodel.graphics.PDXObject

All Implemented Interfaces:
  COSObjectable

Direct Known Subclasses:
  PDFormXObject, PDImageXObject, PDPostScriptXObject

    public class PDXObject
    extends Object
    implements COSObjectable

An external object, or "XObject".

Author:
  Ben Litchfield, John Hewson

### Constructor Summary

Constructors
`protected` `PDXObject(COSStream stream, COSName subtype)` Creates a new XObject from the given stream and subtype.
`protected` `PDXObject(PDDocument document, COSName subtype)` Creates a new XObject of the given subtype for writing.
`protected` `PDXObject(PDStream stream, COSName subtype)` Creates a new XObject from the given stream and subtype.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
`static PDXObject` `createXObject(COSBase base, PDResources resources)` Creates a new XObject instance of the appropriate type for the COS stream.
`COSStream` `getCOSObject()` Returns the stream.
`COSStream` `getCOSStream()` Deprecated. use `getCOSObject()`
`PDStream` `getPDStream()` Deprecated. Use `getStream()` instead.
`PDStream` `getStream()` Returns the stream.

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

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

### Constructor Detail

#### PDXObject

    protected PDXObject(COSStream stream,
                        COSName subtype)

Creates a new XObject from the given stream and subtype.

Parameters:
  `stream` - The stream to read.
  `subtype` -

#### PDXObject

    protected PDXObject(PDStream stream,
                        COSName subtype)

Creates a new XObject from the given stream and subtype.

Parameters:
  `stream` - The stream to read.
  `subtype` -

#### PDXObject

    protected PDXObject(PDDocument document,
                        COSName subtype)

Creates a new XObject of the given subtype for writing.

Parameters:
  `document` - The document in which to create the XObject.
  `subtype` - The subtype of the new XObject.

### Method Detail

#### createXObject

    public static PDXObject createXObject(COSBase base,
                                          PDResources resources)
                                   throws IOException

Creates a new XObject instance of the appropriate type for the COS stream.

Parameters:
  `base` - The stream which is wrapped by this XObject.
  `resources` -
Returns:
  A new XObject instance.
Throws:
  `IOException` - if there is an error creating the XObject.

#### getCOSObject

    public final COSStream getCOSObject()

Returns the stream. Convert this standard java object to a COS object.

Specified by:
  `getCOSObject` in interface `COSObjectable`
Returns:
  The cos object that matches this Java object.

#### getCOSStream

    @Deprecated
    public final COSStream getCOSStream()

Deprecated. use `getCOSObject()`
Returns the stream.

Returns:
  The stream for this object.

#### getPDStream

    @Deprecated
    public final PDStream getPDStream()

Deprecated. Use `getStream()` instead.
Returns the stream.

Returns:
  The stream for this object.

#### getStream

    public final PDStream getStream()

Returns the stream.

Returns:
  The stream for this object.