Package org.apache.pdfbox.pdmodel
Class PDResources
java.lang.Object
org.apache.pdfbox.pdmodel.PDResources
- All Implemented Interfaces:
COSObjectable
A set of resources available at the page/pages/stream level.
- Author:
- Ben Litchfield, John Hewson
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor for embedding.PDResources
(COSDictionary resourceDictionary) Constructor for reading.PDResources
(COSDictionary resourceDictionary, ResourceCache resourceCache) Constructor for reading. -
Method Summary
Modifier and TypeMethodDescriptionadd
(PDPropertyList properties) Adds the given property list to the resources of the current page and returns the name for the new resources.Adds the given font to the resources of the current page and returns the name for the new resources.add
(PDColorSpace colorSpace) Adds the given color space to the resources of the current page and returns the name for the new resources.add
(PDFormXObject form) Adds the given form to the resources of the current page and returns the name for the new resources.add
(PDImageXObject image) Adds the given image to the resources of the current page and returns the name for the new resources.add
(PDAbstractPattern pattern) Adds the given pattern to the resources of the current page and returns the name for the new resources.Adds the given XObject to the resources of the current page and returns the name for the new resources.Adds the given shading to the resources of the current page and returns the name for the new resources.add
(PDExtendedGraphicsState extGState) Adds the given extended graphics state to the resources of the current page and returns the name for the new resources.getColorSpace
(COSName name) Returns the color space resource with the given name, or null if none exists.getColorSpace
(COSName name, boolean wasDefault) Returns the color space resource with the given name, or null if none exists.Returns the names of the color space resources, if any.Returns the underlying dictionary.getExtGState
(COSName name) Returns the extended graphics state resource with the given name, or null if none exists.Returns the names of the extended graphics state resources, if any.Returns the font resource with the given name, or null if none exists.Returns the names of the font resources, if any.getPattern
(COSName name) Returns the pattern resource with the given name, or null if none exists.Returns the names of the pattern resources, if any.getProperties
(COSName name) Returns the property list resource with the given name, or null if none exists.Returns the names of the property list resources, if any.Returns the resource cache associated with the Resources, or null if there is none.getShading
(COSName name) Returns the shading resource with the given name, or null if none exists.Returns the names of the shading resources, if any.getXObject
(COSName name) Returns the XObject resource with the given name, or null if none exists.Returns the names of the XObject resources, if any.boolean
hasColorSpace
(COSName name) Returns true if the given color space name exists in these resources.boolean
isImageXObject
(COSName name) Tells whether the XObject resource with the given name is an image.void
put
(COSName name, PDPropertyList properties) Sets the property list resource with the given name.void
Sets the font resource with the given name.void
put
(COSName name, PDColorSpace colorSpace) Sets the color space resource with the given name.void
put
(COSName name, PDAbstractPattern pattern) Sets the pattern resource with the given name.void
Sets the XObject resource with the given name.void
Sets the shading resource with the given name.void
put
(COSName name, PDExtendedGraphicsState extGState) Sets the extended graphics state resource with the given name.
-
Constructor Details
-
PDResources
public PDResources()Constructor for embedding. -
PDResources
Constructor for reading.- Parameters:
resourceDictionary
- The cos dictionary for this resource.
-
PDResources
Constructor for reading.- Parameters:
resourceDictionary
- The cos dictionary for this resource.resourceCache
- The document's resource cache, may be null.
-
-
Method Details
-
getCOSObject
Returns the underlying dictionary.- Specified by:
getCOSObject
in interfaceCOSObjectable
- Returns:
- The cos object that matches this Java object.
-
getFont
Returns the font resource with the given name, or null if none exists.- Parameters:
name
- Name of the font resource.- Returns:
- the font resource with the given name.
- Throws:
IOException
- if something went wrong.
-
getColorSpace
Returns the color space resource with the given name, or null if none exists.- Parameters:
name
- Name of the color space resource.- Returns:
- a new color space.
- Throws:
IOException
- if something went wrong.
-
getColorSpace
Returns the color space resource with the given name, or null if none exists. This method is for PDFBox internal use only, others should usegetColorSpace(COSName)
.- Parameters:
name
- Name of the color space resource.wasDefault
- if current color space was used by a default color space. This parameter is to- Returns:
- a new color space.
- Throws:
IOException
- if something went wrong.
-
hasColorSpace
Returns true if the given color space name exists in these resources.- Parameters:
name
- Name of the color space resource.- Returns:
- true if the color space with the given name exists.
-
getExtGState
Returns the extended graphics state resource with the given name, or null if none exists.- Parameters:
name
- Name of the graphics state resource.- Returns:
- the extended graphics state resource with the given name.
-
getShading
Returns the shading resource with the given name, or null if none exists.- Parameters:
name
- Name of the shading resource.- Returns:
- the shading resource of the given name.
- Throws:
IOException
- if something went wrong.
-
getPattern
Returns the pattern resource with the given name, or null if none exists.- Parameters:
name
- Name of the pattern resource.- Returns:
- the pattern resource of the given name.
- Throws:
IOException
- if something went wrong.
-
getProperties
Returns the property list resource with the given name, or null if none exists.- Parameters:
name
- Name of the property list resource.- Returns:
- the property list resource of the given name.
-
isImageXObject
Tells whether the XObject resource with the given name is an image.- Parameters:
name
- Name of the XObject resource.- Returns:
- true if it is an image XObject, false if not.
-
getXObject
Returns the XObject resource with the given name, or null if none exists.- Parameters:
name
- Name of the XObject resource.- Returns:
- the XObject resource of the given name.
- Throws:
IOException
- if something went wrong.
-
getColorSpaceNames
Returns the names of the color space resources, if any.- Returns:
- the names of all color space resources.
-
getXObjectNames
Returns the names of the XObject resources, if any.- Returns:
- the names of all XObject resources.
-
getFontNames
Returns the names of the font resources, if any.- Returns:
- the names of all font resources.
-
getPropertiesNames
Returns the names of the property list resources, if any.- Returns:
- the names of all property list resources.
-
getShadingNames
Returns the names of the shading resources, if any.- Returns:
- the names of all shading resources.
-
getPatternNames
Returns the names of the pattern resources, if any.- Returns:
- the names of all pattern resources.
-
getExtGStateNames
Returns the names of the extended graphics state resources, if any.- Returns:
- the names of all extended graphics state resources.
-
add
Adds the given font to the resources of the current page and returns the name for the new resources. Returns the existing resource name if the given item already exists.- Parameters:
font
- the font to add- Returns:
- the name of the resource in the resources dictionary
-
add
Adds the given color space to the resources of the current page and returns the name for the new resources. Returns the existing resource name if the given item already exists.- Parameters:
colorSpace
- the color space to add- Returns:
- the name of the resource in the resources dictionary
-
add
Adds the given extended graphics state to the resources of the current page and returns the name for the new resources. Returns the existing resource name if the given item already exists.- Parameters:
extGState
- the extended graphics state to add- Returns:
- the name of the resource in the resources dictionary
-
add
Adds the given shading to the resources of the current page and returns the name for the new resources. Returns the existing resource name if the given item already exists.- Parameters:
shading
- the shading to add- Returns:
- the name of the resource in the resources dictionary
-
add
Adds the given pattern to the resources of the current page and returns the name for the new resources. Returns the existing resource name if the given item already exists.- Parameters:
pattern
- the pattern to add- Returns:
- the name of the resource in the resources dictionary
-
add
Adds the given property list to the resources of the current page and returns the name for the new resources. Returns the existing resource name if the given item already exists.- Parameters:
properties
- the property list to add- Returns:
- the name of the resource in the resources dictionary
-
add
Adds the given image to the resources of the current page and returns the name for the new resources. Returns the existing resource name if the given item already exists.- Parameters:
image
- the image to add- Returns:
- the name of the resource in the resources dictionary
-
add
Adds the given form to the resources of the current page and returns the name for the new resources. Returns the existing resource name if the given item already exists.- Parameters:
form
- the form to add- Returns:
- the name of the resource in the resources dictionary
-
add
Adds the given XObject to the resources of the current page and returns the name for the new resources. Returns the existing resource name if the given item already exists.- Parameters:
xobject
- the XObject to addprefix
- the prefix to be used when creating the resource name- Returns:
- the name of the resource in the resources dictionary
-
put
Sets the font resource with the given name.- Parameters:
name
- the name of the resourcefont
- the font to be added
-
put
Sets the color space resource with the given name.- Parameters:
name
- the name of the resourcecolorSpace
- the color space to be added
-
put
Sets the extended graphics state resource with the given name.- Parameters:
name
- the name of the resourceextGState
- the extended graphics state to be added
-
put
Sets the shading resource with the given name.- Parameters:
name
- the name of the resourceshading
- the shading to be added
-
put
Sets the pattern resource with the given name.- Parameters:
name
- the name of the resourcepattern
- the pattern to be added
-
put
Sets the property list resource with the given name.- Parameters:
name
- the name of the resourceproperties
- the property list to be added
-
put
Sets the XObject resource with the given name.- Parameters:
name
- the name of the resourcexobject
- the XObject to be added
-
getResourceCache
Returns the resource cache associated with the Resources, or null if there is none.- Returns:
- the resource cache associated with the resources.
-