public class NameTree
extends java.lang.Object
PDFDoc doc = new PDFDoc("../Data/PDFReference.pdf");
NameTree dests = NameTree.find(doc.getSDFDoc(), "Dests");
if (dests.isValid()) {
// Traversing the NameTree
for (DictIterator i = dests.getIterator(); i.hasNext(); i.next())
string key = i.key().getAsPDFText(); // ...
}
Constructor and Description |
---|
NameTree(Obj name_tree)
Create a high level NameTree wrapper around an existing SDF/Cos NameTree.
|
Modifier and Type | Method and Description |
---|---|
static NameTree |
create(Doc doc,
java.lang.String name)
Retrieves the NameTree inside the '/Root/Names' dictionary with the
specified key name, or creates it if it does not exist.
|
void |
erase(byte[] key)
Removes the specified object from the tree.
|
void |
erase(DictIterator pos)
Removes the NameTree entry pointed by the iterator.
|
static NameTree |
find(Doc doc,
java.lang.String name)
Retrieves a name tree, with the given key name, from the '/Root/Names'
dictionary of the doc.
|
NameTreeIterator |
getIterator()
Get the NameTree iterator.
|
NameTreeIterator |
getIterator(byte[] key)
Search for the specified key in the NameTree.
|
Obj |
getSDFObj()
Get the SDFObj.
|
Obj |
getValue(byte[] key)
Get the value of specified key
|
boolean |
isValid()
Checks if NameTree is valid.
|
void |
put(byte[] key,
Obj value)
Puts a new entry in the name tree.
|
public NameTree(Obj name_tree)
name_tree
- SDF/Cos root of the NameTree object.public static NameTree create(Doc doc, java.lang.String name) throws PDFNetException
Note: although it is possible to create a name tree anywhere in the document the convention is that all trees are located under '/Root/Names' dictionary.
doc
- - The document in which the name tree is created.name
- - The name of the NameTree to create.PDFNetException
public static NameTree find(Doc doc, java.lang.String name) throws PDFNetException
doc
- - The document in which to search for the name.name
- - The name of the name tree to find.PDFNetException
public boolean isValid() throws PDFNetException
PDFNetException
public NameTreeIterator getIterator(byte[] key) throws PDFNetException
key
- data buffer representing the key to be found.PDFNetException
- NameTreeIterator i = dests.find("MyKey", 5);
if (i.hasNext()) {
string key = i.getKey().getAsPDFText();
Obj value = i.getValue();
}
public Obj getValue(byte[] key) throws PDFNetException
key
- key of the NameTreePDFNetException
public NameTreeIterator getIterator() throws PDFNetException
for (NameTreeIterator i = dests.getIterator(); i.hasNext(); i.next()) {
string key = i.getKey().getAsPDFText();
}
PDFNetException
public void put(byte[] key, Obj value) throws PDFNetException
key
- data buffer representing the key of the new entry.value
- the valuePDFNetException
public void erase(byte[] key) throws PDFNetException
key
- data buffer representing the key of the entry to be removed.PDFNetException
public void erase(DictIterator pos) throws PDFNetException
pos
- to be deleted NameTreePDFNetException
public Obj getSDFObj()