public class Library
extends java.lang.Object
The Library class acts a central repository for the access
of PDF objects in a document. The Library class has many utility methods
which are designed to access PDF objects as easily as possible. The
Library class has direct access to the PDF file and loads the
needed objects from the file system when needed.
| Modifier and Type | Field and Description |
|---|---|
protected static int |
commonPoolThreads |
protected static java.util.concurrent.ThreadPoolExecutor |
commonThreadPool |
protected static int |
imagePoolThreads |
protected static java.util.concurrent.ThreadPoolExecutor |
imageThreadPool |
protected static int |
painterPoolThreads |
protected static java.util.concurrent.ThreadPoolExecutor |
painterThreadPool |
SecurityManager |
securityManager |
StateManager |
stateManager |
| Constructor and Description |
|---|
Library()
Creates a new instance of a Library.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addObject(java.lang.Object object,
Reference objectReference)
Adds a PDF object and its respective object reference to the library.
|
void |
disposeFontResources()
Utility/demo functionality to clear all font and font descriptor
resources.
|
static void |
execute(java.lang.Runnable runnable) |
static void |
executeImage(java.util.concurrent.FutureTask callable) |
static void |
executePainter(java.lang.Runnable runnable) |
java.util.List |
getArray(java.util.HashMap dictionaryEntries,
Name key) |
java.lang.Boolean |
getBoolean(java.util.HashMap dictionaryEntries,
Name key)
Gets a Boolean specified by the
key in the dictionary
entries. |
Catalog |
getCatalog()
Gets the document's catalog.
|
java.util.HashMap |
getDictionary(java.util.HashMap dictionaryEntries,
Name key)
Gets a dictionary specified by the
key in the dictionary
entries. |
float |
getFloat(java.util.HashMap dictionaryEntries,
Name key)
Gets a float specified by the
key in the dictionary
entries. |
ICCBased |
getICCBased(Reference ref)
The Reference is to the Stream from which the ICC color space data
is to be parsed.
|
ImagePool |
getImagePool() |
int |
getInt(java.util.HashMap dictionaryEntries,
Name key)
Gets an int specified by the
key in the dictionary
entries. |
Font |
getInteractiveFormFont(java.lang.String fontName)
Checks the Catalog for an interactive Forms dictionary and if found the resources object
is used for a font lookup.
|
long |
getLong(java.util.HashMap dictionaryEntries,
Name key)
Gets a float specified by the
key in the dictionary
entries. |
Name |
getName(java.util.HashMap dictionaryEntries,
Name key)
Gets a Name specified by the
key in the dictionary
entries. |
java.lang.Number |
getNumber(java.util.HashMap dictionaryEntries,
Name key)
Gets a Number specified by the
key in the dictionary
entries. |
java.lang.Object |
getObject(java.util.HashMap dictionaryEntries,
Name key)
Gets the PDF object specified by the
key in the dictionary
entries. |
java.lang.Object |
getObject(java.lang.Object referenceObject)
Gets the PDF object that the
referenceObject references. |
java.lang.Object |
getObject(Reference reference)
Gets the object specified by the reference.
|
Reference |
getObjectReference(java.util.HashMap dictionaryEntries,
Name key)
Gets the PDF object specified by the
key in the dictionary
entries. |
java.awt.geom.Rectangle2D.Float |
getRectangle(java.util.HashMap dictionaryEntries,
Name key)
Gets a rectangle specified by the key.
|
Reference |
getReference(java.util.HashMap dictionaryEntries,
Name key)
Gets the reference association of the key if any.
|
Resources |
getResources(java.util.HashMap dictionaryEntries,
Name key) |
Resources |
getResources(Reference reference) |
SecurityManager |
getSecurityManager()
Gets the document's security manger.
|
StateManager |
getStateManager()
Gets the state manager class which keeps track of changes PDF objects.
|
java.lang.String |
getString(java.util.HashMap dictionaryEntries,
Name key)
Gets a text string specified by the
key in the dictionary
entries. |
PTrailer |
getTrailerByFilePosition(long position)
Gets the document's trailer.
|
static void |
initializeThreadPool() |
boolean |
isEncrypted()
Indicates that document is encrypted using Adobe Standard Encryption.
|
boolean |
isLinearTraversal()
There are several implications from using linear traversal, which
affect how we parse the PDF objects, and maintain them in memory,
so those sections of code need to check this flag here.
|
boolean |
isReference(java.util.HashMap dictionaryEntries,
Name key)
Test to see if the given key is a reference and not an inline dictinary
|
boolean |
isValidEntry(java.util.HashMap dictionaryEntries,
Name key)
Tests if the given key will return a non-null PDF object from the
specified dictionary entries.
|
boolean |
isValidEntry(Reference reference)
Tests if there exists a cross-reference entry for this reference.
|
void |
removeObject(Reference objetReference)
Removes an object from from the library.
|
void |
setCatalog(Catalog c)
Sets the document's catalog.
|
void |
setEncrypted(boolean flag)
Set the document is encrypted flag.
|
void |
setLazyObjectLoader(LazyObjectLoader lol)
Sets a document loader for the library.
|
void |
setLinearTraversal()
When we fail to load the required xref tables or streams that are
needed to access the objects in the PDF, then we simply go to the
beginning of the file and read in all of the objects into memory,
which we call linear traversal.
|
void |
setStateManager(StateManager stateManager)
Sets the document state manager so that all object can access the
state manager via the central library instance.
|
static void |
shutdownThreadPool() |
protected static java.util.concurrent.ThreadPoolExecutor commonThreadPool
protected static java.util.concurrent.ThreadPoolExecutor painterThreadPool
protected static java.util.concurrent.ThreadPoolExecutor imageThreadPool
protected static int commonPoolThreads
protected static int painterPoolThreads
protected static int imagePoolThreads
public SecurityManager securityManager
public StateManager stateManager
public void setLazyObjectLoader(LazyObjectLoader lol)
lol - loader object.public PTrailer getTrailerByFilePosition(long position)
position - byte offset of the trailer in the PDF file.public java.lang.Object getObject(Reference reference)
reference - reference to a PDF object in the document structure.public java.lang.Object getObject(java.util.HashMap dictionaryEntries,
Name key)
key in the dictionary
entries. If the key value is a reference, the object that the reference
points to is returned.dictionaryEntries - the dictionary entries to look up the key in.key - string value representing the dictionary key.getObjectReference(java.util.HashMap, Name)public boolean isReference(java.util.HashMap dictionaryEntries,
Name key)
dictionaryEntries - dictionary to testkey - dictionary keypublic Reference getReference(java.util.HashMap dictionaryEntries, Name key)
dictionaryEntries - dictionary to search in.key - key to search for in dictionary.public StateManager getStateManager()
public void setStateManager(StateManager stateManager)
stateManager - public java.lang.Object getObject(java.lang.Object referenceObject)
referenceObject references.referenceObject - reference object.referenceObject references. If
referenceObject is not an instance of a Reference, the
origional referenceObject is returned.public boolean isValidEntry(java.util.HashMap dictionaryEntries,
Name key)
dictionaryEntries - dictionary entrieskey - dictionary keypublic boolean isValidEntry(Reference reference)
reference - reference to a PDF object in the document structure.public java.lang.Number getNumber(java.util.HashMap dictionaryEntries,
Name key)
key in the dictionary
entries. If the key value is a reference, the Number object that the
reference points to is returned.dictionaryEntries - the dictionary entries to look up the key in.key - string value representing the dictionary key.public java.lang.Boolean getBoolean(java.util.HashMap dictionaryEntries,
Name key)
key in the dictionary
entries. If the key value is a reference, the Boolean object that the
reference points to is returned.dictionaryEntries - the dictionary entries to look up the key in.key - string value representing the dictionary key.public float getFloat(java.util.HashMap dictionaryEntries,
Name key)
key in the dictionary
entries. If the key value is a reference, the object that the
reference points to is returned.dictionaryEntries - the dictionary entries to look up the key in.key - string value representing the dictionary key.public int getInt(java.util.HashMap dictionaryEntries,
Name key)
key in the dictionary
entries. If the key value is a reference, the object that the
reference points to is returned.dictionaryEntries - the dictionary entries to look up the key in.key - string value representing the dictionary key.public long getLong(java.util.HashMap dictionaryEntries,
Name key)
key in the dictionary
entries. If the key value is a reference, the object that the
reference points to is returned.dictionaryEntries - the dictionary entries to look up the key in.key - string value representing the dictionary key.public Name getName(java.util.HashMap dictionaryEntries, Name key)
key in the dictionary
entries. If the key value is a reference, the Name object that the
reference points to is returned.dictionaryEntries - the dictionary entries to look up the key in.key - string value representing the dictionary key.public java.lang.String getString(java.util.HashMap dictionaryEntries,
Name key)
key in the dictionary
entries. If the key value is a reference, the string object that the
reference points to is returned.dictionaryEntries - the dictionary entries to look up the key in.key - string value representing the dictionary key.public java.util.HashMap getDictionary(java.util.HashMap dictionaryEntries,
Name key)
key in the dictionary
entries. If the key value is a reference, the dictionary object that the
reference points to is returned.dictionaryEntries - the dictionary entries to look up the key in.key - string value representing the dictionary key.public java.util.List getArray(java.util.HashMap dictionaryEntries,
Name key)
public java.awt.geom.Rectangle2D.Float getRectangle(java.util.HashMap dictionaryEntries,
Name key)
dictionaryEntries - the dictionary entries to look up the key in.key - string value representing the dictionary key.public ICCBased getICCBased(Reference ref)
ref - Reference to Stream containing ICC color space datapublic void addObject(java.lang.Object object,
Reference objectReference)
object - PDF object to add.objectReference - PDF object reference object.public void removeObject(Reference objetReference)
objetReference - object reference to remove to librarypublic Reference getObjectReference(java.util.HashMap dictionaryEntries, Name key)
key in the dictionary
entries. If the key value is a reference it is returned.dictionaryEntries - the dictionary entries to look up the key in.key - string value representing the dictionary key.getObject(java.util.HashMap, Name)public boolean isEncrypted()
public SecurityManager getSecurityManager()
public void setEncrypted(boolean flag)
flag - true, if the document is encrypted; false, otherwize.public void setLinearTraversal()
public boolean isLinearTraversal()
public Catalog getCatalog()
public void setCatalog(Catalog c)
c - document catalog object.public Font getInteractiveFormFont(java.lang.String fontName)
fontName - font name to look for.public void disposeFontResources()
public ImagePool getImagePool()
public static void initializeThreadPool()
public static void shutdownThreadPool()
public static void execute(java.lang.Runnable runnable)
public static void executeImage(java.util.concurrent.FutureTask callable)
public static void executePainter(java.lang.Runnable runnable)