use of com.tom_roush.pdfbox.cos.COSDictionary in project PdfBox-Android by TomRoush.
the class PDDocumentCatalog method getThreads.
/**
* Returns the document's article threads.
*
* @return a list containing all article threads.
*/
public List<PDThread> getThreads() {
COSArray array = (COSArray) root.getDictionaryObject(COSName.THREADS);
if (array == null) {
array = new COSArray();
root.setItem(COSName.THREADS, array);
}
List<PDThread> pdObjects = new ArrayList<PDThread>();
for (int i = 0; i < array.size(); i++) {
pdObjects.add(new PDThread((COSDictionary) array.getObject(i)));
}
return new COSArrayList<PDThread>(pdObjects, array);
}
use of com.tom_roush.pdfbox.cos.COSDictionary in project PdfBox-Android by TomRoush.
the class PDDocumentNameDictionary method getJavaScript.
/**
* Get the document level javascript entries. The values in this name tree
* will be PDTextStream objects.
*
* @return The document level named javascript.
*/
public PDJavascriptNameTreeNode getJavaScript() {
PDJavascriptNameTreeNode retval = null;
COSDictionary dic = (COSDictionary) nameDictionary.getDictionaryObject(COSName.JAVA_SCRIPT);
if (dic != null) {
retval = new PDJavascriptNameTreeNode(dic);
}
return retval;
}
use of com.tom_roush.pdfbox.cos.COSDictionary in project PdfBox-Android by TomRoush.
the class PDPageTree method remove.
/**
* Removes the given COS page.
*/
private void remove(COSDictionary node) {
// remove from parent's kids
COSDictionary parent = (COSDictionary) node.getDictionaryObject(COSName.PARENT, COSName.P);
COSArray kids = (COSArray) parent.getDictionaryObject(COSName.KIDS);
if (kids.removeObject(node)) {
// update ancestor counts
do {
node = (COSDictionary) node.getDictionaryObject(COSName.PARENT, COSName.P);
if (node != null) {
node.setInt(COSName.COUNT, node.getInt(COSName.COUNT) - 1);
}
} while (node != null);
}
}
use of com.tom_roush.pdfbox.cos.COSDictionary in project PdfBox-Android by TomRoush.
the class PDPageTree method getInheritableAttribute.
/**
* Returns the given attribute, inheriting from parent tree nodes if necessary.
*
* @param node page object
* @param key the key to look up
* @return COS value for the given key
*/
public static COSBase getInheritableAttribute(COSDictionary node, COSName key) {
COSBase value = node.getDictionaryObject(key);
if (value != null) {
return value;
}
COSBase base = node.getDictionaryObject(COSName.PARENT, COSName.P);
if (base instanceof COSDictionary) {
COSDictionary parent = (COSDictionary) base;
if (COSName.PAGES.equals(parent.getDictionaryObject(COSName.TYPE))) {
return getInheritableAttribute(parent, key);
}
}
return null;
}
use of com.tom_roush.pdfbox.cos.COSDictionary in project PdfBox-Android by TomRoush.
the class PDPageTree method get.
/**
* Returns the page at the given index.
*
* @param index zero-based index
*
* @return the page at the given index.
*/
public PDPage get(int index) {
COSDictionary dict = get(index + 1, root, 0);
sanitizeType(dict);
ResourceCache resourceCache = document != null ? document.getResourceCache() : null;
return new PDPage(dict, resourceCache);
}
Aggregations