Foxit PDF SDK
com.foxit.sdk.pdf.objects.PDFNumberTree Class Reference
Inheritance diagram for com.foxit.sdk.pdf.objects.PDFNumberTree:
com.foxit.sdk.common.Base

Public Member Functions

 PDFNumberTree (PDFDoc document, int type) throws com.foxit.sdk.PDFException
 Constructor, with parameters. More...
 
 PDFNumberTree ()
 Constructor.
 
 PDFNumberTree (PDFNumberTree other)
 Constructor, with another PDF number tree object. More...
 
synchronized void delete ()
 Clean up related resources immediately. More...
 
PDFObject getObj (int number) throws com.foxit.sdk.PDFException
 Get the value (as PDF object) of a specified key integer. More...
 
int getType () throws com.foxit.sdk.PDFException
 Get the type of current number tree. More...
 
boolean hasNumber (int number) throws com.foxit.sdk.PDFException
 Check if the specified key integer exists in current number tree. More...
 
boolean isEmpty ()
 Check whether current object is empty or not. More...
 
boolean removeAllObjs () throws com.foxit.sdk.PDFException
 Remove all key integers from current number tree, along with theirs value (as PDF object). More...
 
boolean removeObj (int number) throws com.foxit.sdk.PDFException
 Remove a key integer from current number tree, along with its value (as PDF object). More...
 
boolean setObj (int number, PDFObject pdf_object) throws com.foxit.sdk.PDFException
 Set the value (as PDF object) of a specified key integer. If the key integer does not exist, it will be added to current number tree with the value. More...
 
- Public Member Functions inherited from com.foxit.sdk.common.Base
synchronized void delete ()
 Clean up related resources immediately. More...
 

Static Public Attributes

static final int e_PageLabels = 1
 "PageLabels" number tree.
 

Detailed Description

Number tree is a kind of common data structure in PDF. A number tree is similar to a number tree, except that keys in a number tree are integers instead of strings and are sorted in ascending numerical order. Number tree has following characteristics:

  • key integers in a number tree are sorted in ascending numerical order and each key integer in the same number tree is unique;

  • values associated with the key integers may be objects of any type, depending on the purpose of the number tree;

  • number tree can represent an arbitrarily large collection of key-value pairs, which can be looked up efficiently without requiring the entire data structure to be read from the PDF file.

Class PDFNumberTree is used to be associated with an existing number tree with specified type or create one. It offers functions to get key-value pairs in the number tree, and set/add/remove any key-value pair. Currently, class PDFNumberTree can be associated with following number tree defined in PDF document:

  • Page labels number tree (with type com.foxit.sdk.pdf.objects.PDFNumberTree.e_PageLabels ), which defines the page labeling for the document. The keys in this tree are page indexes; the corresponding values are page label dictionaries (Please refer to <PDF Renferece 1.7> P594 Section 8.3.1, "Page Labels"). Each page index denotes the first page in a labeling range to which the specified page label dictionary applies. The tree must include a value for page index 0.

Constructor & Destructor Documentation

◆ PDFNumberTree() [1/2]

com.foxit.sdk.pdf.objects.PDFNumberTree.PDFNumberTree ( PDFDoc  document,
int  type 
) throws com.foxit.sdk.PDFException

Constructor, with parameters.

If there exists number tree with specified type in the PDF document, this function is just to construct a PDF number tree object to be associated with the number tree. If there is no such number tree in PDF document, the constructed PDF number tree object can be used to create such number tree in PDF document and add items to the number tree.

Parameters
[in]documentA valid PDF document object.
[in]typeThe type of the number tree. Please refer to values starting from com.foxit.sdk.pdf.objects.PDFNumberTree.e_PageLabels and this should be one of these values.

◆ PDFNumberTree() [2/2]

com.foxit.sdk.pdf.objects.PDFNumberTree.PDFNumberTree ( PDFNumberTree  other)

Constructor, with another PDF number tree object.

Parameters
[in]otherAnother PDF number tree object.

Member Function Documentation

◆ delete()

synchronized void com.foxit.sdk.pdf.objects.PDFNumberTree.delete ( )

Clean up related resources immediately.

Returns
None.
Note
Once this function is called, current object cannot be used anymore.

◆ getObj()

PDFObject com.foxit.sdk.pdf.objects.PDFNumberTree.getObj ( int  number) throws com.foxit.sdk.PDFException

Get the value (as PDF object) of a specified key integer.

Parameters
[in]numberAn integer as the key.
Returns
A PDFObject object. The type of returned PDF object depends on the purpose of current number tree. Please refer to comment of class PDFNumberTree for more details. If not found, this function will return null.

◆ getType()

int com.foxit.sdk.pdf.objects.PDFNumberTree.getType ( ) throws com.foxit.sdk.PDFException

Get the type of current number tree.

Returns
Type of current number tree. Please refer to values starting from com.foxit.sdk.pdf.objects.PDFNumberTree.e_PageLabels and this would be one of these values.

◆ hasNumber()

boolean com.foxit.sdk.pdf.objects.PDFNumberTree.hasNumber ( int  number) throws com.foxit.sdk.PDFException

Check if the specified key integer exists in current number tree.

Parameters
[in]numberAn integer that represents the key to be checked.
Returns
true means the specified integer exists in current number tree, and false means the specified integer does not exist in current number tree.

◆ isEmpty()

boolean com.foxit.sdk.pdf.objects.PDFNumberTree.isEmpty ( )

Check whether current object is empty or not.

When the current object is empty, that means current object is useless.

Returns
true means current object is empty, while false means not.

◆ removeAllObjs()

boolean com.foxit.sdk.pdf.objects.PDFNumberTree.removeAllObjs ( ) throws com.foxit.sdk.PDFException

Remove all key integers from current number tree, along with theirs value (as PDF object).

Returns
true means success, while false means failure.

◆ removeObj()

boolean com.foxit.sdk.pdf.objects.PDFNumberTree.removeObj ( int  number) throws com.foxit.sdk.PDFException

Remove a key integer from current number tree, along with its value (as PDF object).

If the input key integer does not exist in current number tree, this function will return true directly.

Parameters
[in]numberAn integer as the key to be removed.
Returns
true means success, while false means failure.

◆ setObj()

boolean com.foxit.sdk.pdf.objects.PDFNumberTree.setObj ( int  number,
PDFObject  pdf_object 
) throws com.foxit.sdk.PDFException

Set the value (as PDF object) of a specified key integer. If the key integer does not exist, it will be added to current number tree with the value.

Parameters
[in]numberAn integer as the key.
[in]pdf_objectA PDF object to be set as the key's value. It should not be null. The type of this PDF object should match current number tree; otherwise, the input PDF object is invalid. Please refer to comment of class PDFNumberTree for more details.
User should not release this PDF object after this function succeeds.
Returns
true means success, while false means failure.