Package com.itextpdf.kernel.pdf.canvas
Class CanvasTag
java.lang.Object
com.itextpdf.kernel.pdf.canvas.CanvasTag
- Direct Known Subclasses:
-
CanvasArtifact
This class represents a single tag on a single piece of marked content.
In Tagged PDF, a tag is the basic structure unit for marking content. The tag structure and hierarchy is largely comparable to HTML. As in HTML, every tag type has a name, defined here in the role
attribute. The tagging mechanism in Tagged PDF is extensible, so PDF creators can choose to create custom tags.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected PdfDictionary
The properties of the tag.protected PdfName
The type of the tag. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a tag that is referenced to the document's tag structure (i.e.Creates a tag that is referenced to the document's tag structure (i.e.Creates a tag that is referenced to the document's tag structure (i.e. -
Method Summary
Modifier and TypeMethodDescriptionaddProperty
(PdfName name, PdfObject value) Adds a single property to thetag
's properties.Gets value of /ActualText property.int
getMcid()
Get the marked content id of the tag.Get the properties of the tag.getProperty
(PdfName name) Gets a property from thetag
's properties dictionary.getRole()
Get the role of the tag.boolean
hasMcid()
Determine if an MCID is availableremoveProperty
(PdfName name) Removes a single property from thetag
's properties.setProperties
(PdfDictionary properties) Sets a dictionary of properties to thetag
's properties.
-
Field Details
-
role
The type of the tag. -
properties
The properties of the tag.
-
-
Constructor Details
-
CanvasTag
Creates a tag that is referenced to the document's tag structure (i.e. logical structure).- Parameters:
-
role
- the type of tag
-
CanvasTag
Creates a tag that is referenced to the document's tag structure (i.e. logical structure).- Parameters:
-
role
- the type of tag -
mcid
- marked content id which serves as a reference to the document's logical structure
-
CanvasTag
Creates a tag that is referenced to the document's tag structure (i.e. logical structure).- Parameters:
-
mcr
- theMarked Content Reference
wrapper object
-
-
Method Details
-
getRole
Get the role of the tag.- Returns:
- the role of the tag as a PdfName
-
getMcid
public int getMcid()Get the marked content id of the tag.- Returns:
- marked content id
- Throws:
-
IllegalStateException
- if there is no MCID
-
hasMcid
public boolean hasMcid()Determine if an MCID is available- Returns:
- true if the MCID is available, false otherwise
-
setProperties
Sets a dictionary of properties to thetag
's properties. All existing properties (if any) will be lost.- Parameters:
-
properties
- a dictionary - Returns:
-
current
CanvasTag
-
addProperty
Adds a single property to thetag
's properties.- Parameters:
-
name
- a key -
value
- the value for the key - Returns:
-
current
CanvasTag
-
removeProperty
Removes a single property from thetag
's properties.- Parameters:
-
name
- the key of the key-value pair to be removed - Returns:
-
current
CanvasTag
-
getProperty
Gets a property from thetag
's properties dictionary.- Parameters:
-
name
- the key of the key-value pair to be retrieved - Returns:
- the value corresponding to the key
-
getProperties
Get the properties of the tag.- Returns:
- properties of the tag
-
getActualText
Gets value of /ActualText property.- Returns:
-
actual text value or
null
if actual text is not defined
-
getExpansionText
-