public class COSDocument extends COSBase implements Closeable
| Constructor and Description |
|---|
COSDocument()
Constructor.
|
COSDocument(boolean useScratchFiles)
Constructor.
|
COSDocument(File scratchDir,
boolean useScratchFiles)
Constructor that will use a temporary file in the given directory
for storage of the PDF streams.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
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)
Creates a new COSStream using the current configuration for scratch files.
|
void |
dereferenceObjectStreams()
This method will search the list of objects for types of ObjStm.
|
protected void |
finalize()
Warn the user in the finalizer if he didn't close the PDF document.
|
COSObject |
getCatalog()
This will get the document catalog.
|
COSArray |
getDocumentID()
This will get the document ID.
|
COSDictionary |
getEncryptionDictionary()
This will get the encryption dictionary if the document is encrypted or null
if the document is not encrypted.
|
COSDictionary |
getFirstPageTrailer()
Returns the first page trailer.
|
String |
getHeader() |
int |
getHeaderCommentByte1() |
int |
getHeaderCommentByte2() |
int |
getHeaderCommentByte3() |
int |
getHeaderCommentByte4() |
long |
getHeaderOffset() |
COSObjectKey |
getKey(COSBase object)
Returns the COSObjectKey for a given COS object, or null if there is none.
|
COSDictionary |
getLastTrailer()
This will get the last document trailer.
|
COSObject |
getObjectByType(COSName type)
This will get the first dictionary object by type.
|
COSObject |
getObjectFromPool(COSObjectKey key)
This will get an object from the pool.
|
List<COSObject> |
getObjects()
This will get a list of all available objects.
|
List<COSObject> |
getObjectsByType(COSName type)
This will get a dictionary object by type.
|
List<COSObject> |
getObjectsByType(String type)
This will get all dictionary objects by type.
|
int |
getPostEOFDataSize() |
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 |
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 |
isLinearized() |
Boolean |
isXrefEOLMarkersComplyPDFA() |
boolean |
isXRefStream()
Determines if the trailer is a XRef stream or not.
|
void |
print()
This will print contents to stdout.
|
COSObject |
removeObject(COSObjectKey key)
Removes an object from the object pool.
|
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 |
setFirstPageTrailer(COSDictionary firstPageTrailer) |
void |
setHeader(String header) |
void |
setHeaderCommentByte1(int headerCommentByte1) |
void |
setHeaderCommentByte2(int headerCommentByte2) |
void |
setHeaderCommentByte3(int headerCommentByte3) |
void |
setHeaderCommentByte4(int headerCommentByte4) |
void |
setHeaderOffset(long headerOffset) |
void |
setIsLinearized(boolean isLinearized) |
void |
setIsXRefStream(boolean isXRefStreamValue)
Sets isXRefStream to the given value.
|
void |
setLastTrailer(COSDictionary lastTrailer)
This will set the document trailer.
|
void |
setPostEOFDataSize(int postEOFDataSize) |
void |
setStartXref(long startXrefValue)
This method set the startxref value of the document.
|
void |
setSubsectionHeaderSpaceSeparated(Boolean subsectionHeaderSpaceSeparated) |
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.
|
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. |
void |
setXrefEOLMarkersComplyPDFA(Boolean xrefEOLMarkersComplyPDFA) |
Boolean |
subSectionHeaderSpaceSeparated() |
public COSDocument(boolean useScratchFiles)
useScratchFiles - enables the usage of a scratch file if set to truepublic COSDocument(File scratchDir, boolean useScratchFiles)
scratchDir - directory for the temporary file,
or null to use the system defaultuseScratchFiles - enables the usage of a scratch file if set to truepublic COSDocument()
public int getPostEOFDataSize()
public void setPostEOFDataSize(int postEOFDataSize)
public boolean isLinearized()
public void setIsLinearized(boolean isLinearized)
public Boolean isXrefEOLMarkersComplyPDFA()
public void setXrefEOLMarkersComplyPDFA(Boolean xrefEOLMarkersComplyPDFA)
public Boolean subSectionHeaderSpaceSeparated()
public void setSubsectionHeaderSpaceSeparated(Boolean subsectionHeaderSpaceSeparated)
public void setHeaderOffset(long headerOffset)
public long getHeaderOffset()
public String getHeader()
public void setHeader(String header)
public int getHeaderCommentByte1()
public void setHeaderCommentByte1(int headerCommentByte1)
public int getHeaderCommentByte2()
public void setHeaderCommentByte2(int headerCommentByte2)
public int getHeaderCommentByte3()
public void setHeaderCommentByte3(int headerCommentByte3)
public int getHeaderCommentByte4()
public void setHeaderCommentByte4(int headerCommentByte4)
public COSStream createCOSStream()
public COSStream createCOSStream(COSDictionary dictionary)
dictionary - the corresponding dictionarypublic COSObject getObjectByType(COSName type) throws IOException
type - The type of the object.IOException - If there is an error getting the objectpublic List<COSObject> getObjectsByType(String type) throws IOException
type - The type of the object.IOException - If there is an error getting the objectpublic List<COSObject> getObjectsByType(COSName type) throws IOException
type - The type of the object.IOException - If there is an error getting the objectpublic COSObjectKey getKey(COSBase object)
object - COS objectpublic void print()
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 COSObject getCatalog() throws IOException
IOException - If no catalog can be found.public List<COSObject> getObjects()
public COSDictionary getTrailer()
public void setTrailer(COSDictionary newTrailer)
newTrailer - the document trailer dictionarypublic COSDictionary getFirstPageTrailer()
public void setFirstPageTrailer(COSDictionary firstPageTrailer)
public COSDictionary getLastTrailer()
public void setLastTrailer(COSDictionary lastTrailer)
lastTrailer - the document trailer dictionarypublic Object 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()
protected void finalize()
throws IOException
finalize in class ObjectIOException - if an error occurs while closing the temporary filespublic void setWarnMissingClose(boolean warn)
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.warn - true enables the warning, false disables it.public void dereferenceObjectStreams()
throws IOException
IOException - If there is an error parsing the stream.public COSObject getObjectFromPool(COSObjectKey key) throws IOException
key - The object key.IOException - If there is an error getting the proxy object.public COSObject removeObject(COSObjectKey key)
key - the object keypublic 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 isXRefStreamCopyright © 2015–2020 The veraPDF Consortium. All rights reserved.