Adobe PDF Library

Working with Large Amounts of Data in a PDF

The NameTree and NumberTree are common data structures in PDF files.  They are both dictionaries, but are capable of storing much larger collections of matched pairs of records than a standard object dictionary.  These two sample programs show how to use a NameTree or NumberTree in a PDF file.

NameTrees

View Sample Code

A name tree is a type of dictionary that is often used as a data structure in PDF files. Unlike a standard dictionary, instead of using a code value as a key to identify an object, a name tree uses names as keys to map to data objects. The name in a given dictionary must be associated with an object of a given type. A name tree can hold any number of key value pairs.

When you run the program it will not generate an output file.  Instead you will see a series of statements from the command line, describing a series of steps involved in manipulating data in the NameTree. The program retrieves two entries, compares values, creates a nametree in a document and then deletes it:

C:\DatalogicsAPDFL15.0.4\Java\Sample_Source\ContentCreation\NameTrees
NameTree Sample:
Initialized the library.
Created new document and first page.

Created NameTree and added first key-value pair.
Retrieving two entries:
[ PDFString: Indirect=false, Value=Copasetic, Hex=false ]
[ PDFString: Indirect=false, Value=Smorgasbord, Hex=false ]
After removing entry 1, we now have:

[ PDFString: Indirect=false, Value=Copasetic, Hex=false ]

The two NameTrees abc and xyz are the same

The two NameTrees abc and xyz are not the same

The PDFDict from the NameTree:
[ PDFDict: Indirect=true, ID=5, Generation=0 ]

Killed the NameTree object.
Created a NameTree object in the document.

Two searches for NameTree using getNameTree() method; first fails, second succeeds:

Datalogics.PDFL.NameTree

Remove the NameTree from the document.
Datalogics.PDFL.NameTree

NumberTrees

View Sample Code

A number tree is a type of dictionary that is often used as a data structure in PDF files.  It is similar to a name tree, except that the keys used in a number tree are integers, rather than character strings, and these keys are sorted in ascending numerical order.  Like a name tree, the keys within a number tree can be assigned to any type of object, and a system accessing a number tree can find records quickly, despite a very large number of entries, because the keys are in numerical order.  It isn’t necessary to search the entire data structure to locate a record, and only a subset of the tree is stored in memory at one time.  And a number tree can hold any number of key-value mappings.

When you run the program it will not generate an output file.  Instead you will see a series of statements from the command line, describing a series of steps involved in manipulating data in the NumberTree. The program retrieves two entries, compares values, creates a NumberTree in a document and then deletes it:

C:\DatalogicsAPDFL15.0.4\Java\Sample_Source\ContentCreation\NumberTrees
NumberTree Sample:
Initialized the library.
Created new document and first page.
Created NumberTree and added first key-value pair.

Retrieving two entries:
[ PDFString: Indirect=false, Value=Copasetic, Hex=false ]
[ PDFString: Indirect=false, Value=Smorgasbord, Hex=false ]

After removing entry 1, we now have:

[ PDFString: Indirect=false, Value=Copasetic, Hex=false ]

The two NumberTrees abc and xyz are the same

The two NumberTrees abc and xyz are not the same

The PDFDict from the NumberTree:
[ PDFDict: Indirect=true, ID=5, Generation=0 ]

Killed the NumberTree object.
Killed document object.