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.ObjectThis 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
roleattribute. 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 PdfDictionarypropertiesThe properties of the tag.protected PdfNameroleThe 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 CanvasTagaddProperty(PdfName name, PdfObject value)Adds a single property to thetag's properties.private voidensurePropertiesInit()java.lang.StringgetActualText()Gets value of /ActualText property.java.lang.StringgetExpansionText()intgetMcid()Get the marked content id of the tag.PdfDictionarygetProperties()Get the properties of the tag.PdfObjectgetProperty(PdfName name)Gets a property from thetag's properties dictionary.private java.lang.StringgetPropertyAsString(PdfName name)PdfNamegetRole()Get the role of the tag.booleanhasMcid()Determine if an MCID is availableCanvasTagremoveProperty(PdfName name)Removes a single property from thetag's properties.CanvasTagsetProperties(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 Referencewrapper 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
nullif actual text is not defined
-
getExpansionText
public java.lang.String getExpansionText()
-
getPropertyAsString
private java.lang.String getPropertyAsString(PdfName name)
-
ensurePropertiesInit
private void ensurePropertiesInit()
-
-