Home » pdfbox-1.1.0-src » org.apache.pdfbox.cos » [javadoc | source]
org.apache.pdfbox.cos
public class: COSDocument [javadoc | source]
java.lang.Object
   org.apache.pdfbox.cos.COSBase
      org.apache.pdfbox.cos.COSDocument

All Implemented Interfaces:
    COSObjectable

This is the in-memory representation of the PDF document. You need to call close() on this object when you are done using it!!
Constructor:
 public COSDocument() throws IOException 
    Constructor. Uses the java.io.tmpdir value to create a file to store the streams.
    Throws:
    IOException - If there is an error creating the tmp file.
 public COSDocument(File scratchDir) throws IOException 
    Constructor that will create a create a scratch file in the following directory.
    Parameters:
    scratchDir - The directory to store a scratch file.
    Throws:
    IOException - If there is an error creating the tmp file.
 public COSDocument(RandomAccess file) 
    Constructor that will use the following random access file for storage of the PDF streams. The client of this method is responsible for deleting the storage if necessary that this file will write to. The close method will close the file though.
    Parameters:
    file - The random access file to use for storage.
Method from org.apache.pdfbox.cos.COSDocument Summary:
accept,   close,   dereferenceObjectStreams,   finalize,   getCatalog,   getDocumentID,   getEncryptionDictionary,   getHeaderString,   getObjectByType,   getObjectByType,   getObjectFromPool,   getObjects,   getObjectsByType,   getObjectsByType,   getScratchFile,   getTrailer,   getVersion,   getXrefTable,   isEncrypted,   parseXrefStreams,   print,   setDocumentID,   setEncryptionDictionary,   setHeaderString,   setTrailer,   setVersion,   setWarnMissingClose,   setXRef
Methods from org.apache.pdfbox.cos.COSBase:
accept,   getCOSObject,   getFilterManager
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.pdfbox.cos.COSDocument Detail:
 public Object accept(ICOSVisitor visitor) throws COSVisitorException 
    visitor pattern double dispatch method.
 public  void close() throws IOException 
    This will close all storage and delete the tmp files.
 public  void dereferenceObjectStreams() throws IOException 
    This method will search the list of objects for types of ObjStm. If it finds them then it will parse out all of the objects from the stream that is contains.
 protected  void finalize() throws IOException 
    Warn the user in the finalizer if he didn't close the PDF document. The method also closes the document just in case, to avoid abandoned temporary files. It's still a good idea for the user to close the PDF document at the earliest possible to conserve resources.
 public COSObject getCatalog() throws IOException 
    This will get the document catalog. Maybe this should move to an object at PDFEdit level
 public COSArray getDocumentID() 
    This will get the document ID.
 public COSDictionary getEncryptionDictionary() 
    This will get the encryption dictionary if the document is encrypted or null if the document is not encrypted.
 public String getHeaderString() 
 public COSObject getObjectByType(String type) throws IOException 
    This will get the first dictionary object by type.
 public COSObject getObjectByType(COSName type) throws IOException 
    This will get the first dictionary object by type.
 public COSObject getObjectFromPool(COSObjectKey key) throws IOException 
    This will get an object from the pool.
 public List<COSObject> getObjects() 
    This will get a list of all available objects.
 public List<COSObject> getObjectsByType(String type) throws IOException 
    This will get all dictionary objects by type.
 public List<COSObject> getObjectsByType(COSName type) throws IOException 
    This will get a dictionary object by type.
 public RandomAccess getScratchFile() 
    This will get the scratch file for this document.
 public COSDictionary getTrailer() 
    This will get the document trailer.
 public float getVersion() 
    This will get the version of this PDF document.
 public Map<COSObjectKey, Integer> getXrefTable() 
    Returns the xrefTable which is a mapping of ObjectKeys to byte offsets in the file.
 public boolean isEncrypted() 
    This will tell if this is an encrypted document.
 public  void parseXrefStreams() throws IOException 
    This method will search the list of objects for types of XRef and uses the parsed data to populate the trailer information as well as the xref Map.
 public  void print() 
    This will print contents to stdout.
 public  void setDocumentID(COSArray id) 
    This will set the document ID.
 public  void setEncryptionDictionary(COSDictionary encDictionary) 
    This will set the encryption dictionary, this should only be called when encypting the document.
 public  void setHeaderString(String header) 
 public  void setTrailer(COSDictionary newTrailer) 
    // MIT added, maybe this should not be supported as trailer is a persistence construct. This will set the document trailer.
 public  void setVersion(float versionValue) 
    This will set the version of this PDF document.
 public  void setWarnMissingClose(boolean warn) 
    Controls whether this instance shall issue a warning if the PDF document wasn't closed properly through a call to the #close() method. If the PDF document is held in a cache governed by soft references it is impossible to reliably close the document before the warning is raised. By default, the warning is enabled.
 public  void setXRef(COSObjectKey objKey,
    int offset) 
    Used to populate the XRef HashMap. Will add an Xreftable entry that maps ObjectKeys to byte offsets in the file.