Class PDFormXObject
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.graphics.PDXObject
-
- org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject
-
- All Implemented Interfaces:
PDContentStream
,COSObjectable
- Direct Known Subclasses:
PDAppearanceStream
,PDTransparencyGroup
public class PDFormXObject extends PDXObject implements PDContentStream
A Form XObject.
-
-
Field Summary
Fields Modifier and Type Field Description private ResourceCache
cache
private PDTransparencyGroupAttributes
group
-
Constructor Summary
Constructors Constructor Description PDFormXObject(COSStream stream)
Creates a Form XObject for reading.PDFormXObject(COSStream stream, ResourceCache cache)
Creates a Form XObject for reading.PDFormXObject(PDStream stream)
Creates a Form XObject for reading.PDFormXObject(PDDocument document)
Creates a Form Image XObject for writing, in the given document.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PDRectangle
getBBox()
An array of four numbers in the form coordinate system (see below), giving the coordinates of the left, bottom, right, and top edges, respectively, of the form XObject's bounding box.java.io.InputStream
getContents()
Returns this stream's content, if any.PDStream
getContentStream()
int
getFormType()
This will get the form type, currently 1 is the only form type.PDTransparencyGroupAttributes
getGroup()
Returns the group attributes dictionary.Matrix
getMatrix()
This will get the optional matrix of an XObjectForm.PDPropertyList
getOptionalContent()
This will get the optional content group or optional content membership dictionary.PDResources
getResources()
This will get the resources for this Form XObject.int
getStructParents()
This will get the key of this XObjectForm in the structural parent tree.void
setBBox(PDRectangle bbox)
This will set the BBox (bounding box) for this form.void
setFormType(int formType)
Set the form type.void
setMatrix(java.awt.geom.AffineTransform transform)
Sets the optional Matrix entry for the form XObject.void
setOptionalContent(PDPropertyList oc)
Sets the optional content group or optional content membership dictionary.void
setResources(PDResources resources)
This will set the resources for this page.void
setStructParents(int structParent)
This will set the key for this XObjectForm in the structural parent tree.-
Methods inherited from class org.apache.pdfbox.pdmodel.graphics.PDXObject
createXObject, getCOSObject, getCOSStream, getPDStream, getStream
-
-
-
-
Field Detail
-
group
private PDTransparencyGroupAttributes group
-
cache
private final ResourceCache cache
-
-
Constructor Detail
-
PDFormXObject
public PDFormXObject(PDStream stream)
Creates a Form XObject for reading.- Parameters:
stream
- The XObject stream
-
PDFormXObject
public PDFormXObject(COSStream stream)
Creates a Form XObject for reading.- Parameters:
stream
- The XObject stream
-
PDFormXObject
public PDFormXObject(COSStream stream, ResourceCache cache)
Creates a Form XObject for reading.- Parameters:
stream
- The XObject stream
-
PDFormXObject
public PDFormXObject(PDDocument document)
Creates a Form Image XObject for writing, in the given document.- Parameters:
document
- The current document
-
-
Method Detail
-
getFormType
public int getFormType()
This will get the form type, currently 1 is the only form type.- Returns:
- The form type.
-
setFormType
public void setFormType(int formType)
Set the form type.- Parameters:
formType
- The new form type.
-
getGroup
public PDTransparencyGroupAttributes getGroup()
Returns the group attributes dictionary.- Returns:
- the group attributes dictionary
-
getContentStream
public PDStream getContentStream()
-
getContents
public java.io.InputStream getContents() throws java.io.IOException
Description copied from interface:PDContentStream
Returns this stream's content, if any.- Specified by:
getContents
in interfacePDContentStream
- Returns:
- An InputStream or null.
- Throws:
java.io.IOException
- If the stream could not be read
-
getResources
public PDResources getResources()
This will get the resources for this Form XObject. This will return null if no resources are available.- Specified by:
getResources
in interfacePDContentStream
- Returns:
- The resources for this Form XObject.
-
setResources
public void setResources(PDResources resources)
This will set the resources for this page.- Parameters:
resources
- The new resources for this page.
-
getBBox
public PDRectangle getBBox()
An array of four numbers in the form coordinate system (see below), giving the coordinates of the left, bottom, right, and top edges, respectively, of the form XObject's bounding box. These boundaries are used to clip the form XObject and to determine its size for caching.- Specified by:
getBBox
in interfacePDContentStream
- Returns:
- The BBox of the form.
-
setBBox
public void setBBox(PDRectangle bbox)
This will set the BBox (bounding box) for this form.- Parameters:
bbox
- The new BBox for this form.
-
getMatrix
public Matrix getMatrix()
This will get the optional matrix of an XObjectForm. It maps the form space to user space.- Specified by:
getMatrix
in interfacePDContentStream
- Returns:
- the form matrix if available, or the identity matrix.
-
setMatrix
public void setMatrix(java.awt.geom.AffineTransform transform)
Sets the optional Matrix entry for the form XObject.- Parameters:
transform
- the transformation matrix
-
getStructParents
public int getStructParents()
This will get the key of this XObjectForm in the structural parent tree. Required if the form XObject contains marked-content sequences that are structural content items.- Returns:
- the integer key of the XObjectForm's entry in the structural parent tree or -1 if there isn't any.
-
setStructParents
public void setStructParents(int structParent)
This will set the key for this XObjectForm in the structural parent tree.- Parameters:
structParent
- The new key for this XObjectForm.
-
getOptionalContent
public PDPropertyList getOptionalContent()
This will get the optional content group or optional content membership dictionary.- Returns:
- The optional content group or optional content membership dictionary or null if there is none.
-
setOptionalContent
public void setOptionalContent(PDPropertyList oc)
Sets the optional content group or optional content membership dictionary.- Parameters:
oc
- The optional content group or optional content membership dictionary.
-
-