Class PdfStructElem
- All Implemented Interfaces:
-
IStructureNode
The logical structure of a document shall be described by a hierarchy of objects called the structure hierarchy or structure tree. At the root of the hierarchy shall be a dictionary object called the structure tree root (see PdfStructTreeRoot
). Immediate children of the structure tree root are structure elements. Structure elements are other structure elements or content items.
-
Constructor Summary
ConstructorDescriptionPdfStructElem
(PdfDictionary pdfObject) PdfStructElem
(PdfDocument document, PdfName role) PdfStructElem
(PdfDocument document, PdfName role, PdfAnnotation annot) PdfStructElem
(PdfDocument document, PdfName role, PdfPage page) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds file associated with structure element and identifies the relationship between them.void
addAssociatedFile
(String description, PdfFileSpec fs) Adds file associated with structure element and identifies the relationship between them.addKid
(int index, PdfStructElem kid) addKid
(PdfStructElem kid) void
addRef
(PdfStructElem ref) APdfName.Ref
identifies the structure element to which the item of content, contained within this structure element, refers (e.g.void
flush()
getAlt()
getAssociatedFiles
(boolean create) Returns files associated with structure element.getAttributes
(boolean createNewIfNull) Gets attributes object.protected PdfDocument
getE()
getK()
getKids()
Gets list of the direct kids of structure element.getLang()
A namespace this element belongs to (see ISO 32000-2 14.7.4, "Namespaces").Attribute for a structure element that may be used as pronunciation hint.Attribute for a structure element that indicates the phonetic alphabet used by aPdfName.Phoneme
attribute.APdfName.Ref
identifies the structure element or elements to which the item of content, contained within this structure element, refers (e.g.getRole()
Gets the structure element's ID string, if it has one.static boolean
isStructElem
(PdfDictionary dictionary) Method to distinguish struct elements from other elements of the logical tree (like mcr or struct tree root).protected boolean
Defines if the object behind this wrapper must be an indirect object in the resultant document.removeKid
(int index) removeKid
(int index, boolean prepareForReAdding) int
removeKid
(IStructureNode kid) void
setActualText
(PdfString actualText) void
void
setAttributes
(PdfObject attributes) void
void
void
setNamespace
(PdfNamespace namespace) A namespace this element belongs to (see ISO 32000-2 14.7.4, "Namespaces").void
setPhoneme
(PdfString elementPhoneme) Attribute for a structure element that may be used as pronunciation hint.void
setPhoneticAlphabet
(PdfName phoneticAlphabet) Attribute for a structure element that indicates the phonetic alphabet used by aPdfName.Phoneme
attribute.void
void
Sets the structure element's ID string.Methods inherited from class com.itextpdf.kernel.pdf.PdfObjectWrapper
ensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
-
Constructor Details
-
PdfStructElem
-
PdfStructElem
-
PdfStructElem
-
PdfStructElem
-
-
Method Details
-
isStructElem
Method to distinguish struct elements from other elements of the logical tree (like mcr or struct tree root).- Parameters:
-
dictionary
- thePdfDictionary
to check on containing struct elements - Returns:
-
if the type of
PdfDictionary
is StructElem orPdfDictionary
contains the required key S then true, otherwise false
-
getAttributes
Gets attributes object.- Parameters:
-
createNewIfNull
- sometimes attributes object may not exist. Passtrue
if you want to create empty dictionary in such case. The attributes dictionary will be stored inside element. - Returns:
- attributes dictionary.
-
setAttributes
-
getLang
-
setLang
-
getAlt
-
setAlt
-
getActualText
-
setActualText
-
getE
-
setE
-
getStructureElementId
Gets the structure element's ID string, if it has one.- Returns:
- the structure element's ID string, or null if there is none
-
setStructureElementId
Sets the structure element's ID string. This value can be used by other structure elements to reference this one.- Parameters:
-
id
- the element's ID string to be set
-
getRole
- Specified by:
-
getRole
in interfaceIStructureNode
-
setRole
-
addKid
-
addKid
-
addKid
-
addKid
-
removeKid
-
removeKid
-
removeKid
-
getParent
- Specified by:
-
getParent
in interfaceIStructureNode
- Returns:
- parent of the current structure element. Returns null if parent isn't set or if either current element or parent are invalid.
-
getKids
Gets list of the direct kids of structure element. If certain kid is flushed, there will be anull
in the list on it's place.- Specified by:
-
getKids
in interfaceIStructureNode
- Returns:
- list of the direct kids of structure element.
-
getK
-
getRefsList
APdfName.Ref
identifies the structure element or elements to which the item of content, contained within this structure element, refers (e.g. footnotes, endnotes, sidebars, etc.).- Returns:
-
a
List
<PdfStructElem
> containing zero, one or more structure elements.
-
addRef
APdfName.Ref
identifies the structure element to which the item of content, contained within this structure element, refers (e.g. footnotes, endnotes, sidebars, etc.).This value has meaning only for the PDF documents of version 2.0 and higher.
- Parameters:
-
ref
- aPdfStructElem
to which the item of content, contained within this structure element, refers.
-
getNamespace
A namespace this element belongs to (see ISO 32000-2 14.7.4, "Namespaces"). If not present, the element shall be considered to be in the default standard structure namespace.- Returns:
-
a
PdfNamespace
this element belongs to.
-
setNamespace
A namespace this element belongs to (see ISO 32000-2 14.7.4, "Namespaces").This value has meaning only for the PDF documents of version 2.0 and higher.
- Parameters:
-
namespace
- aPdfNamespace
this element belongs to, or null if element is desired to be considered in the default standard structure namespace.
-
setPhoneme
Attribute for a structure element that may be used as pronunciation hint. It is an exact replacement for content enclosed by the structure element and its children.This value has meaning only for the PDF documents of version 2.0 and higher.
- Parameters:
-
elementPhoneme
- aPdfString
which defines an exact replacement for content enclosed by the structure element and its children. This value is to be interpreted based on the PhoneticAlphabet attribute in effect.
-
getPhoneme
Attribute for a structure element that may be used as pronunciation hint. It is an exact replacement for content enclosed by the structure element and its children.- Returns:
-
a
PdfString
which defines an exact replacement for content enclosed by the structure element and its children. This value is to be interpreted based on the PhoneticAlphabet attribute in effect.
-
setPhoneticAlphabet
Attribute for a structure element that indicates the phonetic alphabet used by aPdfName.Phoneme
attribute. Applies to the structure element and its children, except where overridden by a child structure element.This value has meaning only for the PDF documents of version 2.0 and higher.
- Parameters:
-
phoneticAlphabet
- thePdfName
which defines phonetic alphabet used by aPdfName.Phoneme
attribute. Possible values are:PdfName.ipa
for the International Phonetic Alphabet by the International Phonetic Association;PdfName.x_sampa
for Extended Speech Assessment Methods Phonetic Alphabet (X-SAMPA);PdfName.zh_Latn_pinyin
for Pinyin Latin romanization (Mandarin);PdfName.zh_Latn_wadegile
for Wade-Giles romanization (Mandarin).
-
getPhoneticAlphabet
Attribute for a structure element that indicates the phonetic alphabet used by aPdfName.Phoneme
attribute. Applies to the structure element and its children, except where overridden by a child structure element.- Returns:
-
the
PdfName
which defines phonetic alphabet used by aPdfName.Phoneme
, or null if not defined, default valuePdfName.ipa
. SeesetPhoneticAlphabet(PdfName)
for other possible values.
-
addAssociatedFile
Adds file associated with structure element and identifies the relationship between them.Associated files may be used in Pdf/A-3 and Pdf 2.0 documents. The method adds file to array value of the AF key in the structure element dictionary. If description is provided, it also will add file description to catalog Names tree.
For associated files their associated file specification dictionaries shall include the AFRelationship key
- Parameters:
-
description
- the file description -
fs
- file specification dictionary of associated file
-
addAssociatedFile
Adds file associated with structure element and identifies the relationship between them.
Associated files may be used in Pdf/A-3 and Pdf 2.0 documents. The method adds file to array value of the AF key in the structure element dictionary.
For associated files their associated file specification dictionaries shall include the AFRelationship key
- Parameters:
-
fs
- file specification dictionary of associated file
-
getAssociatedFiles
Returns files associated with structure element.- Parameters:
-
create
- defines whether AF arrays will be created if it doesn't exist - Returns:
- associated files array
-
put
-
flush
public void flush()- Overrides:
-
flush
in classPdfObjectWrapper<PdfDictionary>
-
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.
-
getDocument
-