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
ConstructorsConstructorDescriptionCreates new instance from empty dictionary.PdfResources(PdfDictionary pdfObject) Creates new instance from given dictionary. -
Method Summary
Modifier and TypeMethodDescriptionAddsPdfColorSpaceobject to the resources.addColorSpace(PdfObject colorSpace) AddsPdfObjectto the resources as color space.addExtGState(PdfExtGState extGState) AddsPdfExtGStateobject to the resources.addExtGState(PdfDictionary extGState) AddsPdfDictionaryto 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.AddsPdfStreamto the resources as form.addForm(PdfFormXObject form) AddsPdfFormXObjectobject to the resources.addForm(PdfFormXObject form, PdfName name) Adds the given Form XObject to the current instance ofPdfResources.AddsPdfStreamto the resources as image.addImage(PdfImageXObject image) AddsPdfImageXObjectobject to the resources.addPattern(PdfPattern pattern) AddsPdfPatternobject to the resources.addPattern(PdfDictionary pattern) AddsPdfDictionaryto the resources as pattern.addProperties(PdfDictionary properties) AddsPdfDictionaryto the resources as properties list.protected voidaddResource(PdfObject resource, PdfName resType, PdfName resName) addShading(AbstractPdfShading shading) AddsAbstractPdfShadingobject to the resources.addShading(PdfDictionary shading) AddsPdfDictionaryto the resources as shading dictionary.protected voidbuildResources(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 thePdfDictionaryobject 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 thePdfObjectunder 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 thePdfObjectobject with specified type and name.getShading(PdfName name) protected booleanprotected booleanprotected booleanDefines if the object behind this wrapper must be an indirect object in the resultant document.voidsetDefaultCmyk(PdfColorSpace defaultCs) Sets the value of default CMYK Color Space (see ISO-320001 Paragraph 8.6.5.6).voidsetDefaultGray(PdfColorSpace defaultCs) Sets the value of default Gray Color Space (see ISO-320001 Paragraph 8.6.5.6).voidsetDefaultRgb(PdfColorSpace defaultCs) Sets the value of default RGB Color Space (see ISO-320001 Paragraph 8.6.5.6).voidsetProcSet(PdfArray array) Sets the array of predefined procedure set names (see ISO-320001 Paragraph 14.2).protected voidsetReadOnly(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- thePdfDictionaryobject 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- aPdfDocumentinstance to which the font is added for further flushing -
font- aPdfFontinstance to be added - Returns:
- added font resource name.
-
addImage
AddsPdfImageXObjectobject to the resources.- Parameters:
-
image- thePdfImageXObjectto add. - Returns:
- added image resource name.
-
addImage
AddsPdfStreamto the resources as image.- Parameters:
-
image- thePdfStreamto add. - Returns:
- added image resources name.
-
getImage
-
addForm
AddsPdfFormXObjectobject to the resources.- Parameters:
-
form- thePdfFormXObjectto add. - Returns:
- added form resource name.
-
addForm
AddsPdfStreamto the resources as form.- Parameters:
-
form- thePdfStreamto 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
PdfNameof the newly added resource
-
getForm
-
addExtGState
AddsPdfExtGStateobject to the resources.- Parameters:
-
extGState- thePdfExtGStateto add. - Returns:
- added graphics state parameter dictionary resource name.
-
addExtGState
AddsPdfDictionaryto the resources as graphics state parameter dictionary.- Parameters:
-
extGState- thePdfDictionaryto add. - Returns:
- added graphics state parameter dictionary resources name.
-
getPdfExtGState
-
addProperties
AddsPdfDictionaryto the resources as properties list.- Parameters:
-
properties- thePdfDictionaryto add. - Returns:
- added properties list resources name.
-
getProperties
-
addColorSpace
AddsPdfColorSpaceobject to the resources.- Parameters:
-
cs- thePdfColorSpaceto add. - Returns:
- added color space resource name.
-
addColorSpace
AddsPdfObjectto the resources as color space.- Parameters:
-
colorSpace- thePdfObjectto add. - Returns:
- added color space resources name.
-
getColorSpace
-
addPattern
AddsPdfPatternobject to the resources.- Parameters:
-
pattern- thePdfPatternto add. - Returns:
- added pattern resource name.
-
addPattern
AddsPdfDictionaryto the resources as pattern.- Parameters:
-
pattern- thePdfDictionaryto add. - Returns:
- added pattern resources name.
-
getPattern
-
addShading
AddsAbstractPdfShadingobject to the resources.- Parameters:
-
shading- theAbstractPdfShadingto add. - Returns:
- added shading resource name.
-
addShading
AddsPdfDictionaryto the resources as shading dictionary.- Parameters:
-
shading- thePdfDictionaryto add. - Returns:
- added shading dictionary resources name.
-
getShading
-
isReadOnly
protected boolean isReadOnly() -
setReadOnly
protected void setReadOnly(boolean readOnly) -
isModified
protected boolean isModified() -
setModified
- Overrides:
-
setModifiedin 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 thePdfObjectunder 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
nullif 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 thePdfDictionaryobject 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
PdfDictionaryobject containing all resources of specified type, ornullin case of incorrect resource type.
-
getResourceObject
Get thePdfObjectobject 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
PdfObjectwith specified name in the resources of specified type ornullin case of incorrect type or missing resource with such name.
-
isWrappedObjectMustBeIndirect
protected boolean isWrappedObjectMustBeIndirect()Description copied from class:PdfObjectWrapperDefines 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:
-
isWrappedObjectMustBeIndirectin classPdfObjectWrapper<PdfDictionary> - Returns:
- true if in the resultant document the object behind the wrapper must be indirect, otherwise false.
-
addResource
-
buildResources
-