public class COSDocument extends COSBase implements Closeable
| Constructor and Description |
|---|
COSDocument()
Constructor.
|
COSDocument(ICOSParser parser)
Constructor.
|
COSDocument(org.apache.pdfbox.io.RandomAccessStreamCache.StreamCacheCreateFunction streamCacheCreateFunction)
Constructor that will use the provided function to create a stream cache for the storage of the PDF streams.
|
COSDocument(org.apache.pdfbox.io.RandomAccessStreamCache.StreamCacheCreateFunction streamCacheCreateFunction,
ICOSParser parser)
Constructor that will use the provided function to create a stream cache for the storage of the PDF streams.
|
| Modifier and Type | Method and Description |
|---|---|
void |
accept(ICOSVisitor visitor)
visitor pattern double dispatch method.
|
void |
addXRefTable(Map<COSObjectKey,Long> xrefTableValues)
Populate XRef HashMap with given values.
|
void |
close()
This will close all storage and delete the tmp files.
|
COSStream |
createCOSStream()
Creates a new COSStream using the current configuration for scratch files.
|
COSStream |
createCOSStream(COSDictionary dictionary,
long startPosition,
long streamLength)
Creates a new COSStream using the current configuration for scratch files.
|
COSArray |
getDocumentID()
This will get the document ID.
|
COSDocumentState |
getDocumentState()
Returns the
COSDocumentState of this COSDocument. |
COSDictionary |
getEncryptionDictionary()
This will get the encryption dictionary if the document is encrypted or null if the document
is not encrypted.
|
long |
getHighestXRefObjectNumber()
Internal PDFBox use only.
|
COSDictionary |
getLinearizedDictionary()
Get the dictionary containing the linearization information if the pdf is linearized.
|
COSObject |
getObjectFromPool(COSObjectKey key)
This will get an object from the pool.
|
List<COSObject> |
getObjectsByType(COSName type)
This will get all dictionaries objects by type.
|
List<COSObject> |
getObjectsByType(COSName type1,
COSName type2)
This will get all dictionaries objects by type.
|
long |
getStartXref()
Return the startXref Position of the parsed document.
|
COSDictionary |
getTrailer()
This will get the document trailer.
|
float |
getVersion()
This will get the version extracted from the header of this PDF document.
|
Map<COSObjectKey,Long> |
getXrefTable()
Returns the xrefTable which is a mapping of ObjectKeys
to byte offsets in the file.
|
boolean |
hasHybridXRef()
Determines if the pdf has hybrid cross references, both plain tables and streams.
|
boolean |
isClosed()
Returns true if this document has been closed.
|
boolean |
isDecrypted()
Indicates if a encrypted pdf is already decrypted after parsing.
|
boolean |
isEncrypted()
This will tell if this is an encrypted document.
|
boolean |
isXRefStream()
Determines if the trailer is a XRef stream or not.
|
void |
setDecrypted()
Signals that the document is decrypted completely.
|
void |
setDocumentID(COSArray id)
This will set the document ID.
|
void |
setEncryptionDictionary(COSDictionary encDictionary)
This will set the encryption dictionary, this should only be called when
encrypting the document.
|
void |
setHasHybridXRef()
Marks the pdf as document using hybrid cross references.
|
void |
setHighestXRefObjectNumber(long highestXRefObjectNumber)
Internal PDFBox use only.
|
void |
setIsXRefStream(boolean isXRefStreamValue)
Sets isXRefStream to the given value.
|
void |
setStartXref(long startXrefValue)
This method set the startxref value of the document.
|
void |
setTrailer(COSDictionary newTrailer)
// MIT added, maybe this should not be supported as trailer is a persistence construct.
|
void |
setVersion(float versionValue)
This will set the header version of this PDF document.
|
public COSDocument()
public COSDocument(ICOSParser parser)
parser - Parser to be used to parse the document on demandpublic COSDocument(org.apache.pdfbox.io.RandomAccessStreamCache.StreamCacheCreateFunction streamCacheCreateFunction)
streamCacheCreateFunction - a function to create an instance of a stream cachepublic COSDocument(org.apache.pdfbox.io.RandomAccessStreamCache.StreamCacheCreateFunction streamCacheCreateFunction,
ICOSParser parser)
streamCacheCreateFunction - a function to create an instance of a stream cacheparser - Parser to be used to parse the document on demandpublic COSStream createCOSStream()
public COSStream createCOSStream(COSDictionary dictionary, long startPosition, long streamLength) throws IOException
dictionary - the corresponding dictionarystartPosition - the start position within the sourcestreamLength - the stream lengthIOException - if the random access view can't be readpublic COSDictionary getLinearizedDictionary()
public List<COSObject> getObjectsByType(COSName type)
type - The type of the object.public List<COSObject> getObjectsByType(COSName type1, COSName type2)
type1 - The first possible type of the object, mandatory.type2 - The second possible type of the object, usually an abbreviation, optional.public void setVersion(float versionValue)
versionValue - The version of the PDF document.public float getVersion()
public void setDecrypted()
public boolean isDecrypted()
public boolean isEncrypted()
public COSDictionary getEncryptionDictionary()
public void setEncryptionDictionary(COSDictionary encDictionary)
encDictionary - The encryption dictionary.public COSArray getDocumentID()
public void setDocumentID(COSArray id)
id - The document id.public COSDictionary getTrailer()
public void setTrailer(COSDictionary newTrailer)
newTrailer - the document trailer dictionarypublic long getHighestXRefObjectNumber()
public void setHighestXRefObjectNumber(long highestXRefObjectNumber)
highestXRefObjectNumber - The object number of the highest XRef stream.public void accept(ICOSVisitor visitor) throws IOException
accept in class COSBasevisitor - The object to notify when visiting this object.IOException - If an error occurs while visiting this object.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOException - If there is an error close resources.public boolean isClosed()
public COSObject getObjectFromPool(COSObjectKey key)
key - The object key.public void addXRefTable(Map<COSObjectKey,Long> xrefTableValues)
xrefTableValues - xref table entries to be addedpublic Map<COSObjectKey,Long> getXrefTable()
public void setStartXref(long startXrefValue)
startXrefValue - the value for startXrefpublic long getStartXref()
public boolean isXRefStream()
public void setIsXRefStream(boolean isXRefStreamValue)
isXRefStreamValue - the new value for isXRefStreampublic boolean hasHybridXRef()
public void setHasHybridXRef()
public COSDocumentState getDocumentState()
COSDocumentState of this COSDocument.COSDocumentState of this COSDocument.COSDocumentStateCopyright © 2002–2022 The Apache Software Foundation. All rights reserved.