Package com.itextpdf.kernel.pdf.canvas
Class CanvasTag
- java.lang.Object
-
- com.itextpdf.kernel.pdf.canvas.CanvasTag
-
- Direct Known Subclasses:
CanvasArtifact
public class CanvasTag extends java.lang.Object
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
Fields Modifier and Type Field Description protected PdfDictionary
properties
The properties of the tag.protected PdfName
role
The type of the tag.
-
Constructor Summary
Constructors Constructor Description CanvasTag(PdfName role)
Creates a tag that is referenced to the document's tag structure (i.e.CanvasTag(PdfName role, int mcid)
Creates a tag that is referenced to the document's tag structure (i.e.CanvasTag(PdfMcr mcr)
Creates a tag that is referenced to the document's tag structure (i.e.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CanvasTag
addProperty(PdfName name, PdfObject value)
Adds a single property to thetag
's properties.private void
ensurePropertiesInit()
java.lang.String
getActualText()
Gets value of /ActualText property.java.lang.String
getExpansionText()
int
getMcid()
Get the marked content id of the tag.PdfDictionary
getProperties()
Get the properties of the tag.PdfObject
getProperty(PdfName name)
Gets a property from thetag
's properties dictionary.private java.lang.String
getPropertyAsString(PdfName name)
PdfName
getRole()
Get the role of the tag.boolean
hasMcid()
Determine if an MCID is availableCanvasTag
removeProperty(PdfName name)
Removes a single property from thetag
's properties.CanvasTag
setProperties(PdfDictionary properties)
Sets a dictionary of properties to thetag
's properties.
-
-
-
Field Detail
-
role
protected PdfName role
The type of the tag.
-
properties
protected PdfDictionary properties
The properties of the tag.
-
-
Constructor Detail
-
CanvasTag
public CanvasTag(PdfName role)
Creates a tag that is referenced to the document's tag structure (i.e. logical structure).- Parameters:
role
- the type of tag
-
CanvasTag
public CanvasTag(PdfName role, int mcid)
Creates a tag that is referenced to the document's tag structure (i.e. logical structure).- Parameters:
role
- the type of tagmcid
- marked content id which serves as a reference to the document's logical structure
-
CanvasTag
public CanvasTag(PdfMcr mcr)
Creates a tag that is referenced to the document's tag structure (i.e. logical structure).- Parameters:
mcr
- theMarked Content Reference
wrapper object
-
-
Method Detail
-
getRole
public PdfName 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:
java.lang.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
public CanvasTag setProperties(PdfDictionary properties)
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
public CanvasTag addProperty(PdfName name, PdfObject value)
Adds a single property to thetag
's properties.- Parameters:
name
- a keyvalue
- the value for the key- Returns:
- current
CanvasTag
-
removeProperty
public CanvasTag removeProperty(PdfName name)
Removes a single property from thetag
's properties.- Parameters:
name
- the key of the key-value pair to be removed- Returns:
- current
CanvasTag
-
getProperty
public PdfObject getProperty(PdfName name)
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
public PdfDictionary getProperties()
Get the properties of the tag.- Returns:
- properties of the tag
-
getActualText
public java.lang.String getActualText()
Gets value of /ActualText property.- Returns:
- actual text value or
null
if actual text is not defined
-
getExpansionText
public java.lang.String getExpansionText()
-
getPropertyAsString
private java.lang.String getPropertyAsString(PdfName name)
-
ensurePropertiesInit
private void ensurePropertiesInit()
-
-