Package com.itextpdf.kernel.pdf
Class PdfResources
Wrapper class that represent resource dictionary - that define named resources used by content streams operators. (ISO 32000-1, 7.8.3 Resource Dictionaries)
-
Constructor Summary
ConstructorDescriptionCreates new instance from empty dictionary.PdfResources
(PdfDictionary pdfObject) Creates new instance from given dictionary. -
Method Summary
Modifier and TypeMethodDescriptionAddsPdfColorSpace
object to the resources.addColorSpace
(PdfObject colorSpace) AddsPdfObject
to the resources as color space.addExtGState
(PdfExtGState extGState) AddsPdfExtGState
object to the resources.addExtGState
(PdfDictionary extGState) AddsPdfDictionary
to the resources as graphics state parameter dictionary.addFont
(PdfDocument pdfDocument, PdfFont font) Adds font to resources and registers PdfFont in the document for further flushing.AddsPdfStream
to the resources as form.addForm
(PdfFormXObject form) AddsPdfFormXObject
object to the resources.addForm
(PdfFormXObject form, PdfName name) Adds the given Form XObject to the current instance ofPdfResources
.AddsPdfStream
to the resources as image.addImage
(PdfImageXObject image) AddsPdfImageXObject
object to the resources.addPattern
(PdfPattern pattern) AddsPdfPattern
object to the resources.addPattern
(PdfDictionary pattern) AddsPdfDictionary
to the resources as pattern.addProperties
(PdfDictionary properties) AddsPdfDictionary
to the resources as properties list.protected void
addResource
(PdfObject resource, PdfName resType, PdfName resName) addShading
(PdfShading shading) AddsPdfShading
object to the resources.addShading
(PdfDictionary shading) AddsPdfDictionary
to the resources as shading dictionary.protected void
buildResources
(PdfDictionary dictionary) getColorSpace
(PdfName name) getPattern
(PdfName name) getPdfExtGState
(PdfName name) Gets the array of predefined procedure set names (see ISO-320001 Paragraph 14.2).getProperties
(PdfName name) getResource
(PdfName resType) Get thePdfDictionary
object that that contain resources of specified type.getResourceName
(PdfObject resource) Gets the mapped resource name of the givenPdfObject
.PdfObject>
PdfNamegetResourceName
(PdfObjectWrapper resource) Gets the mapped resource name of thePdfObject
under the given wrapper.Gets the names of all the added resources.getResourceNames
(PdfName resType) Gets the names of all resources of specified type.getResourceObject
(PdfName resType, PdfName resName) Get thePdfObject
object with specified type and name.getShading
(PdfName name) protected boolean
protected boolean
protected boolean
Defines if the object behind this wrapper must be an indirect object in the resultant document.void
setDefaultCmyk
(PdfColorSpace defaultCs) Sets the value of default CMYK Color Space (see ISO-320001 Paragraph 8.6.5.6).void
setDefaultGray
(PdfColorSpace defaultCs) Sets the value of default Gray Color Space (see ISO-320001 Paragraph 8.6.5.6).void
setDefaultRgb
(PdfColorSpace defaultCs) Sets the value of default RGB Color Space (see ISO-320001 Paragraph 8.6.5.6).void
setProcSet
(PdfArray array) Sets the array of predefined procedure set names (see ISO-320001 Paragraph 14.2).protected void
setReadOnly
(boolean readOnly) Methods inherited from class com.itextpdf.kernel.pdf.PdfObjectWrapper
ensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, flush, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setPdfObject, unsetForbidRelease
-
Constructor Details
-
PdfResources
Creates new instance from given dictionary.- Parameters:
-
pdfObject
- thePdfDictionary
object from which the resource object will be created.
-
PdfResources
public PdfResources()Creates new instance from empty dictionary.
-
-
Method Details
-
addFont
Adds font to resources and registers PdfFont in the document for further flushing.- Parameters:
-
pdfDocument
- aPdfDocument
instance to which the font is added for further flushing -
font
- aPdfFont
instance to be added - Returns:
- added font resource name.
-
addImage
AddsPdfImageXObject
object to the resources.- Parameters:
-
image
- thePdfImageXObject
to add. - Returns:
- added image resource name.
-
addImage
AddsPdfStream
to the resources as image.- Parameters:
-
image
- thePdfStream
to add. - Returns:
- added image resources name.
-
getImage
-
addForm
AddsPdfFormXObject
object to the resources.- Parameters:
-
form
- thePdfFormXObject
to add. - Returns:
- added form resource name.
-
addForm
AddsPdfStream
to the resources as form.- Parameters:
-
form
- thePdfStream
to add. - Returns:
- added form resources name.
-
addForm
Adds the given Form XObject to the current instance ofPdfResources
.- Parameters:
-
form
- Form XObject. -
name
- Preferred name for the given Form XObject. - Returns:
-
the
PdfName
of the newly added resource
-
getForm
-
addExtGState
AddsPdfExtGState
object to the resources.- Parameters:
-
extGState
- thePdfExtGState
to add. - Returns:
- added graphics state parameter dictionary resource name.
-
addExtGState
AddsPdfDictionary
to the resources as graphics state parameter dictionary.- Parameters:
-
extGState
- thePdfDictionary
to add. - Returns:
- added graphics state parameter dictionary resources name.
-
getPdfExtGState
-
addProperties
AddsPdfDictionary
to the resources as properties list.- Parameters:
-
properties
- thePdfDictionary
to add. - Returns:
- added properties list resources name.
-
getProperties
-
addColorSpace
AddsPdfColorSpace
object to the resources.- Parameters:
-
cs
- thePdfColorSpace
to add. - Returns:
- added color space resource name.
-
addColorSpace
AddsPdfObject
to the resources as color space.- Parameters:
-
colorSpace
- thePdfObject
to add. - Returns:
- added color space resources name.
-
getColorSpace
-
addPattern
AddsPdfPattern
object to the resources.- Parameters:
-
pattern
- thePdfPattern
to add. - Returns:
- added pattern resource name.
-
addPattern
AddsPdfDictionary
to the resources as pattern.- Parameters:
-
pattern
- thePdfDictionary
to add. - Returns:
- added pattern resources name.
-
getPattern
-
addShading
AddsPdfShading
object to the resources.- Parameters:
-
shading
- thePdfShading
to add. - Returns:
- added shading resource name.
-
addShading
AddsPdfDictionary
to the resources as shading dictionary.- Parameters:
-
shading
- thePdfDictionary
to add. - Returns:
- added shading dictionary resources name.
-
getShading
-
isReadOnly
protected boolean isReadOnly() -
setReadOnly
protected void setReadOnly(boolean readOnly) -
isModified
protected boolean isModified() -
setModified
- Overrides:
-
setModified
in classPdfObjectWrapper<PdfDictionary>
-
setDefaultGray
Sets the value of default Gray Color Space (see ISO-320001 Paragraph 8.6.5.6).- Parameters:
-
defaultCs
- the color space to set.
-
setDefaultRgb
Sets the value of default RGB Color Space (see ISO-320001 Paragraph 8.6.5.6).- Parameters:
-
defaultCs
- the color space to set.
-
setDefaultCmyk
Sets the value of default CMYK Color Space (see ISO-320001 Paragraph 8.6.5.6).- Parameters:
-
defaultCs
- the color space to set.
-
getResourceName
Gets the mapped resource name of thePdfObject
under the given wrapper.
Note: if the name for the object won't be found, then the name of object's Indirect Reference will be searched. -
getResourceName
Gets the mapped resource name of the givenPdfObject
.
Note: if the name for the object won't be found, then the name of object's Indirect Reference will be searched.- Parameters:
-
resource
- the object, for which the name will be searched. - Returns:
-
the mapped resource name or
null
if object isn't added to resources.
-
getResourceNames
Gets the names of all the added resources.- Returns:
- the name of all the added resources.
-
getProcSet
Gets the array of predefined procedure set names (see ISO-320001 Paragraph 14.2). Deprecated in PDF 2.0.- Returns:
- the array of predefined procedure set names.
-
setProcSet
Sets the array of predefined procedure set names (see ISO-320001 Paragraph 14.2). Deprecated in PDF 2.0.- Parameters:
-
array
- the array of predefined procedure set names to be set.
-
getResourceNames
Gets the names of all resources of specified type.- Parameters:
-
resType
- the resource type. Should bePdfName.ColorSpace
,PdfName.ExtGState
,PdfName.Pattern
,PdfName.Shading
,PdfName.XObject
,PdfName.Font
. - Returns:
- set of resources name of corresponding type. May be empty. Will be empty in case of incorrect resource type.
-
getResource
Get thePdfDictionary
object that that contain resources of specified type.- Parameters:
-
resType
- the resource type. Should bePdfName.ColorSpace
,PdfName.ExtGState
,PdfName.Pattern
,PdfName.Shading
,PdfName.XObject
,PdfName.Font
. - Returns:
-
the
PdfDictionary
object containing all resources of specified type, ornull
in case of incorrect resource type.
-
getResourceObject
Get thePdfObject
object with specified type and name.- Parameters:
-
resType
- the resource type. Should bePdfName.ColorSpace
,PdfName.ExtGState
,PdfName.Pattern
,PdfName.Shading
,PdfName.XObject
,PdfName.Font
. -
resName
- the name of the resource object. - Returns:
-
the
PdfObject
with specified name in the resources of specified type ornull
in case of incorrect type or missing resource with such name.
-
isWrappedObjectMustBeIndirect
protected boolean isWrappedObjectMustBeIndirect()Description copied from class:PdfObjectWrapper
Defines if the object behind this wrapper must be an indirect object in the resultant document.
If this method returns true it doesn't necessarily mean that object must be in the indirect state at any moment, but rather defines that when the object will be written to the document it will be transformed into indirect object if it's not indirect yet.
Return value of this method shouldn't depend on any logic, it should return always true or false.- Specified by:
-
isWrappedObjectMustBeIndirect
in classPdfObjectWrapper<PdfDictionary>
- Returns:
- true if in the resultant document the object behind the wrapper must be indirect, otherwise false.
-
addResource
-
buildResources
-