Class CosDocument
- java.lang.Object
-
- com.adobe.internal.pdftoolkit.core.cos.CosDocument
-
public final class CosDocument extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close theCosDocumentand free any resources associated with it.CosArraycreateCosArray()Creates a new, empty COS array object.CosArraycreateCosArray(int directStatus)Creates a new, empty COS array object.CosArraycreateCosArray(java.util.ArrayList array)Creates a new COS array object and populates it with the specified ArrayList of CosObjects.CosArraycreateCosArray(java.util.ArrayList array, int directStatus)Creates a new COS array object and populates it with the specified ArrayList of CosObjects.CosArraycreateCosArrayFromNonCosData(java.util.ArrayList array)Creates a new COS array object and populates it with the specified ArrayList of non CosObjects.CosArraycreateCosArrayFromNonCosData(java.util.ArrayList array, int directStatus)Creates a new COS array object and populates it with the specified ArrayList of non CosObjects.CosBooleancreateCosBoolean(boolean value)Create a new CosBoolean instance (always a direct object)CosBooleancreateCosBoolean(java.lang.Boolean value)Create a new CosBoolean instance (always a direct object)CosDictionarycreateCosDictionary()Creates an empty COS dictionary.CosDictionarycreateCosDictionary(int directStatus)Creates an empty COS dictionary.CosDictionarycreateCosDictionary(java.util.Map cosData)Creates a COS dictionary from a Map of Cos objects.CosDictionarycreateCosDictionary(java.util.Map cosData, int directStatus)Creates a COS dictionary from a Map of Cos objects based on the value of the directStatus enum.CosDictionarycreateCosDictionaryFromNonCosData(java.util.Map javaMap)Creates a COS dictionary from non CosObject data.CosDictionarycreateCosDictionaryFromNonCosData(java.util.Map data, int directStatus)Constructs COS dictionary from the HashMap that contains non-Cos object values.CosNamecreateCosName(ASName value)Creates a COS name object corresponding to the specified atom.CosNullcreateCosNull()Creates a COS null object.CosNumericcreateCosNumeric(byte[] inputRep)Creates a COS numeric value object.CosNumericcreateCosNumeric(double value)Creates a COS numeric value object.CosNumericcreateCosNumeric(int value)Creates a COS numeric value object.CosNumericcreateCosNumeric(long value)Creates a COS numeric value object.CosNumericcreateCosNumeric(CosNumeric source)Creates a COS numeric value object.CosNumericcreateCosNumeric(java.lang.Number value)Creates a COS numeric value object.CosObjectStreamcreateCosObjectStream()Create a new, initialized CosObjectStream instanceCosStreamcreateCosStream()Creates a COS stream with an empty stream data.CosStreamcreateCosStream(InputByteStream data)Creates a CosStream object.CosStringcreateCosString(byte[] value)Creates a COS string object.CosStringcreateCosString(ASString value)Creates a COS string object.CosStringcreateCosString(java.lang.String value)Creates a COS string object.CosDictionarycreateDirectCosDictionary()Creates an empty COS dictionary.CosDictionarycreateDirectCosDictionary(java.util.Map cosData)Creates a COS dictionary from a Map of Cos objects.CosDictionarycreateDirectCosDictionaryFromNonCosData(java.util.Map javaMap)Creates a COS dictionary from non CosObject data.CosStringcreateHexCosString(byte[] value)Creates a COS hex string object.CosStringcreateHexCosString(ASString value)Creates a COS hex string object.CosStringcreateHexCosString(java.lang.String value)Creates a COS hex string object.CosArraycreateIndirectCosArray()Creates a new, empty COS array object.CosArraycreateIndirectCosArray(java.util.ArrayList array)Creates a new COS array object and populates it with the specified ArrayList of CosObjects.CosArraycreateIndirectCosArrayFromNonCosData(java.util.ArrayList array)Creates a new COS array object and populates it with the specified ArrayList of non CosObjects.PDFCorefinish()voidfreeDuplicateResources()Parse the document to identify and remove duplicate resources referenced in the page resource object trees.booleanfreeUnreferencedObjects()Explicit early cleanup of unreferenced objects as done in full save.ByteReadergetByteReader()CosListgetChangedObjects(long eof)Return CosLIst of objects added, deleted, or changed since EOF value.CosEncryptiongetEncryption()longgetEOF()java.lang.ObjectgetFdfDocument()Returns pointer to FDFDocumentlonggetFileSize()intgetHeaderTrashCount()Return the count of trash bytes that appear before the document header.CosObjectgetIndirectObjectByNumber(int objNum)Return an indirect CosObject instance corresponding to an object number.CosObjectInfogetIndirectObjectInfoByNumber(int objNum)Return an indirect CosObjectInfo instance corresponding to an object number.CosDictionarygetInfo()Retrieves the Information CosDictionary of the document, may be null.ByteWritergetInPlaceByteWriter()static java.lang.StringgetLoggingPath()intgetNumObjects()intgetNumRevisions()Get total number of revisions for this document.longgetObjEOF(CosObject obj)Return EOF of object's update section or zero if cannot be determined.intgetObjRevision(CosObject obj)Return index of object's update section or -1 if cannot be determined.CosOpenOptionsgetOptions()java.lang.StringgetOriginalVersion()Returns the version string of the PDF file (e.g.java.lang.ObjectgetPdfDocument()Gets pointer to PDFDocumentjava.util.EnumSet<REPAIRTYPE>getRepairTypes()CosDictionarygetRoot()Retrieves the root CosDictionary of the document if it's not already cached; otherwise, returns the cached root.InputByteStreamgetStream()Obtain a slice of the underlying InputByteStream for the document.InputByteStreamgetStream(long start, long length)Obtain a slice of the underlying InputByteStream for the document.StreamManagergetStreamManager()Get theStreamManagerto use for this document.java.util.MapgetToSaveExtensions()java.lang.StringgetToSaveVersion()CosDictionarygetTrailer()Retrieves the trailer from the document.CosDictionary[]getTrailerList()intgetTrailerTrashCount()Return the count of trash bytes that appear after the document trailer.CosObject[]getUnreferencedObjects()Return an array of unreferenced indirect objects in this document.intgetXRefType()Get the current XRef typebooleanisCacheEnabled()booleanisDirty()Is the document dirty?booleanisEncrypted()booleanisLinearized()Returns true iff the document is currently linearized.booleanisToSaveExtensionsInitialized()voidmarkDirty()booleanmarkNotDirty()Mark document as not dirty.static CosDocumentnewDocument(ByteReader byteReader, CosOpenOptions options)Returns an empty document with some initialized data structures so that you can build a new CosDocument.static CosDocumentnewDocument(CosOpenOptions options)Returns an empty document with some initialized data structures so that you can build a new CosDocument.static CosDocumentnewDocument(PDFCore pdfCore)Once a CosDocument was instanciated from a PDFCore object, that PDFCore object can't be used again.java.lang.StringprocureOriginalVersion()java.lang.StringprocureToSaveVersion()voidsave(ByteWriter byteWriter, CosSaveParams params)Perform an save with previously specified save stylevoidsetFDFDocument(java.lang.Object fdfDocument)Sets pointer to FDFDocumentstatic voidsetLoggingPath(java.lang.String loggingPath)voidsetNextIncrementalSectionOffset(long nextIncrementalSectionOffset)Sets the offset where next incremental section shall be written if the document is saved incrementally.voidsetPDFDocument(java.lang.Object pdfdocument)Sets pointer to PDFDocumentvoidsetToSaveExtensions(java.util.Map extensions)voidsetToSaveVersion(java.lang.String version)voidsetUseRepairList(boolean useRepairList)For some API's such as PDF/A validation Gibson needs to work on original cos objects and ignore repairs made to cos objects.booleanwasLinearized()Returns true iff the BASE document was a linearized document, but later suffered incremental updates that spoil its perfect order.booleanwasRepaired()
-
-
-
Method Detail
-
newDocument
public static CosDocument newDocument(ByteReader byteReader, CosOpenOptions options) throws PDFCosParseException, PDFIOException, PDFSecurityException
Returns an empty document with some initialized data structures so that you can build a new CosDocument.- Parameters:
byteReader- the PDF data for the documentoptions- the options to provide for the new document- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
newDocument
public static CosDocument newDocument(CosOpenOptions options) throws PDFCosParseException, PDFIOException, PDFSecurityException
Returns an empty document with some initialized data structures so that you can build a new CosDocument.- Parameters:
options- the options to provide for the new document- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
newDocument
public static CosDocument newDocument(PDFCore pdfCore) throws PDFCosParseException, PDFIOException, PDFSecurityException
Once a CosDocument was instanciated from a PDFCore object, that PDFCore object can't be used again. You can generate a new PDFCore object by calling CosDocument.finish().- Parameters:
pdfCore-- Returns:
- CosDocument from the input PDFCore.
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
getStreamManager
public StreamManager getStreamManager()
Get theStreamManagerto use for this document.- Returns:
- the stream manager for this document
-
finish
public PDFCore finish()
- Returns:
- new PDFCore which can be used to reinstantiate a CosDocument
-
close
public void close() throws PDFIOException, PDFCosParseException, PDFSecurityExceptionClose theCosDocumentand free any resources associated with it.
-
getOriginalVersion
public java.lang.String getOriginalVersion() throws PDFCosParseException, PDFIOException, PDFSecurityExceptionReturns the version string of the PDF file (e.g. "1.5"). This string is typically found in the header of the file. However, the version also can be an entry in the catalog; if the version is more recent and the file has been saved incrementally, the version entry in the catalog overrides the header. A newly created document will not have a header yet, and the version information will either have to be put in the catalog or supplied explicitly to the save routine when the document is first written. The version string is discussed in sections 3.4.1 and H.1 of the PDF Reference Manual version 1.4.- Returns:
- PDF file version string.
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
procureOriginalVersion
public java.lang.String procureOriginalVersion() throws PDFCosParseException, PDFIOException, PDFSecurityException
-
getToSaveExtensions
public java.util.Map getToSaveExtensions()
-
setToSaveExtensions
public void setToSaveExtensions(java.util.Map extensions)
-
isToSaveExtensionsInitialized
public boolean isToSaveExtensionsInitialized()
-
getToSaveVersion
public java.lang.String getToSaveVersion()
-
setToSaveVersion
public void setToSaveVersion(java.lang.String version)
-
procureToSaveVersion
public java.lang.String procureToSaveVersion() throws PDFCosParseException, PDFIOException, PDFSecurityException
-
getTrailer
public CosDictionary getTrailer()
Retrieves the trailer from the document.- Returns:
- Document's trailer dictionary.
-
getTrailerList
public CosDictionary[] getTrailerList()
-
getRoot
public CosDictionary getRoot() throws PDFCosParseException, PDFIOException, PDFSecurityException
Retrieves the root CosDictionary of the document if it's not already cached; otherwise, returns the cached root.- Returns:
- Document's Root dictionary
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
getInfo
public CosDictionary getInfo() throws PDFCosParseException, PDFIOException, PDFSecurityException
Retrieves the Information CosDictionary of the document, may be null.- Returns:
- Document's Information dictionary
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
getStream
public InputByteStream getStream(long start, long length) throws PDFIOException
Obtain a slice of the underlying InputByteStream for the document. This slice belongs to the caller of this method and must be closed by them when they are finished with it.- Parameters:
start- the offset in theCosDocument'sInputByteStreamto use as the start of the returned slicelength- the length of the slice to create- Returns:
- A slice of the underlying InputByteStream for the document.
- Throws:
PDFIOException
-
getStream
public InputByteStream getStream() throws PDFIOException
Obtain a slice of the underlying InputByteStream for the document. This slice belongs to the caller of this method and must be closed by them when they are finished with it.- Returns:
- A slice of the underlying InputByteStream for the document.
- Throws:
PDFIOException
-
getNumObjects
public int getNumObjects()
-
getOptions
public CosOpenOptions getOptions()
-
isLinearized
public boolean isLinearized()
Returns true iff the document is currently linearized. To say that a document is "linearized" in PDF means it has been put into the special order and has NOT been modified since then.
-
wasLinearized
public boolean wasLinearized()
Returns true iff the BASE document was a linearized document, but later suffered incremental updates that spoil its perfect order. So if isLinearized() returns false but wasLinearized() returns true you are dealing with a document that was linear saved and has not been full saved since then but that HAS had one or more incremental update sections applied to it.
-
wasRepaired
public boolean wasRepaired()
-
getRepairTypes
public java.util.EnumSet<REPAIRTYPE> getRepairTypes()
-
setFDFDocument
public void setFDFDocument(java.lang.Object fdfDocument)
Sets pointer to FDFDocument- Parameters:
fdfDocument- FDFDocument to set
-
getFdfDocument
public java.lang.Object getFdfDocument()
Returns pointer to FDFDocument- Returns:
- Object
-
setPDFDocument
public void setPDFDocument(java.lang.Object pdfdocument)
Sets pointer to PDFDocument- Parameters:
pdfdocument- PDFDocument to set
-
getPdfDocument
public java.lang.Object getPdfDocument()
Gets pointer to PDFDocument- Returns:
- Object
-
freeDuplicateResources
public void freeDuplicateResources() throws PDFCosParseException, PDFIOException, PDFSecurityExceptionParse the document to identify and remove duplicate resources referenced in the page resource object trees.Note: This method must be explicitly invoked by the client prior to save. It should only be invoked before full save and linear save.
-
freeUnreferencedObjects
public boolean freeUnreferencedObjects() throws PDFCosParseException, PDFIOException, PDFSecurityExceptionExplicit early cleanup of unreferenced objects as done in full save. returns true if at least one object is freed.
-
getUnreferencedObjects
public CosObject[] getUnreferencedObjects() throws PDFCosParseException, PDFIOException, PDFSecurityException
Return an array of unreferenced indirect objects in this document.
-
save
public void save(ByteWriter byteWriter, CosSaveParams params) throws PDFCosParseException, PDFInvalidParameterException, PDFIOException, PDFSecurityException
Perform an save with previously specified save style- Parameters:
byteWriter- for writing the PDF document toparams- indicating save style- Throws:
PDFCosParseExceptionPDFInvalidParameterExceptionPDFIOExceptionPDFSecurityException
-
setLoggingPath
public static void setLoggingPath(java.lang.String loggingPath)
-
getLoggingPath
public static java.lang.String getLoggingPath()
-
getInPlaceByteWriter
public ByteWriter getInPlaceByteWriter()
-
getByteReader
public ByteReader getByteReader()
- Returns:
ByteReader
-
setNextIncrementalSectionOffset
public void setNextIncrementalSectionOffset(long nextIncrementalSectionOffset)
Sets the offset where next incremental section shall be written if the document is saved incrementally.- Parameters:
nextIncrementalSectionOffset-
-
isCacheEnabled
public boolean isCacheEnabled()
-
isEncrypted
public boolean isEncrypted()
-
getEncryption
public CosEncryption getEncryption()
-
getIndirectObjectByNumber
public CosObject getIndirectObjectByNumber(int objNum) throws PDFCosParseException, PDFIOException, PDFSecurityException
Return an indirect CosObject instance corresponding to an object number. If this CosDocument instance is not already caching the CosObject, use the XRef table (if there are entries) to locate the object in the input stream and parse it. Cache it for future references.- Parameters:
objNum- Indirect object number of COS object whose byte location is desired- Returns:
- CosObject parsed result. Returns null if object doesn't exist or if the object entry in the XRef is marked free.
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
getIndirectObjectInfoByNumber
public CosObjectInfo getIndirectObjectInfoByNumber(int objNum) throws PDFCosParseException, PDFIOException, PDFSecurityException
Return an indirect CosObjectInfo instance corresponding to an object number. If this CosDocument instance is not already caching the CosObjectInfo, use the XRef table (if there are entries) to look it up and cache it for future references.
-
getObjEOF
public long getObjEOF(CosObject obj)
Return EOF of object's update section or zero if cannot be determined.
-
getObjRevision
public int getObjRevision(CosObject obj)
Return index of object's update section or -1 if cannot be determined.
-
getHeaderTrashCount
public int getHeaderTrashCount()
Return the count of trash bytes that appear before the document header.
-
getTrailerTrashCount
public int getTrailerTrashCount()
Return the count of trash bytes that appear after the document trailer.
-
getNumRevisions
public int getNumRevisions()
Get total number of revisions for this document.
-
getFileSize
public long getFileSize() throws PDFIOException- Returns:
- the length of the underly buffer in bytes
- Throws:
PDFIOException
-
getChangedObjects
public CosList getChangedObjects(long eof) throws PDFCosParseException, PDFIOException, PDFSecurityException
Return CosLIst of objects added, deleted, or changed since EOF value.
-
markDirty
public void markDirty()
-
isDirty
public boolean isDirty()
Is the document dirty?- Returns:
trueif the document is dirty;falseotherwise
-
markNotDirty
public boolean markNotDirty()
Mark document as not dirty.- Returns:
- previous dirty state
-
getEOF
public long getEOF() throws PDFIOException- Throws:
PDFIOException
-
getXRefType
public int getXRefType()
Get the current XRef type
-
createCosArray
public CosArray createCosArray(java.util.ArrayList array, int directStatus) throws PDFCosParseException, PDFIOException, PDFSecurityException
Creates a new COS array object and populates it with the specified ArrayList of CosObjects. The created CosArray container can be made direct or indirect by setting the directStatus flag.- Parameters:
array- - ArrayList of CosObjects that becomes the data in the new CosArray object- Returns:
- A newly created CosArray.
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
createIndirectCosArray
public CosArray createIndirectCosArray(java.util.ArrayList array) throws PDFCosParseException, PDFIOException, PDFSecurityException
Creates a new COS array object and populates it with the specified ArrayList of CosObjects. The created CosArray container will be INDIRECT.- Parameters:
array- - ArrayList of CosObjects that becomes the data in the new CosArray object- Returns:
- A newly created CosArray.
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
createCosArray
public CosArray createCosArray(java.util.ArrayList array) throws PDFCosParseException, PDFIOException, PDFSecurityException
Creates a new COS array object and populates it with the specified ArrayList of CosObjects. The created CosArray container will be DIRECT.- Parameters:
array- - ArrayList of CosObjects that becomes the data in the new CosArray object- Returns:
- A newly created CosArray.
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
createCosArrayFromNonCosData
public CosArray createCosArrayFromNonCosData(java.util.ArrayList array, int directStatus) throws PDFCosParseException, PDFIOException, PDFSecurityException
Creates a new COS array object and populates it with the specified ArrayList of non CosObjects. The created CosArray container can be made direct or indirect by setting the directStatus flag.- Parameters:
array- - ArrayList of non CosObjects that becomes the data in the new CosArray object- Returns:
- A newly created CosArray.
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
createIndirectCosArrayFromNonCosData
public CosArray createIndirectCosArrayFromNonCosData(java.util.ArrayList array) throws PDFCosParseException, PDFIOException, PDFSecurityException
Creates a new COS array object and populates it with the specified ArrayList of non CosObjects. The created CosArray container will be INDIRECT.- Parameters:
array- - ArrayList of non CosObjects that becomes the data in the new CosArray object- Returns:
- A newly created CosArray.
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
createCosArrayFromNonCosData
public CosArray createCosArrayFromNonCosData(java.util.ArrayList array) throws PDFCosParseException, PDFIOException, PDFSecurityException
Creates a new COS array object and populates it with the specified ArrayList of non CosObjects. The created CosArray container will be DIRECT.- Parameters:
array- - ArrayList of non CosObjects that becomes the data in the new CosArray object- Returns:
- A newly created CosArray.
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
createCosArray
public CosArray createCosArray(int directStatus) throws PDFCosParseException, PDFIOException, PDFSecurityException
Creates a new, empty COS array object. Array will be direct or indirect depending on the value of the directStatus enum.- Returns:
- A newly allocated COS array.
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
createIndirectCosArray
public CosArray createIndirectCosArray() throws PDFCosParseException, PDFIOException, PDFSecurityException
Creates a new, empty COS array object. Array will be INDIRECT.- Returns:
- A newly allocated COS array.
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
createCosArray
public CosArray createCosArray() throws PDFCosParseException, PDFIOException, PDFSecurityException
Creates a new, empty COS array object. Array will be DIRECT.- Returns:
- A newly allocated COS array.
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
createCosBoolean
public CosBoolean createCosBoolean(boolean value)
Create a new CosBoolean instance (always a direct object)- Parameters:
value- - boolean value attribute of the instance- Returns:
- - CosBoolean new instance
-
createCosBoolean
public CosBoolean createCosBoolean(java.lang.Boolean value)
Create a new CosBoolean instance (always a direct object)- Parameters:
value- - Boolean value attribute of the instance- Returns:
- - CosBoolean new instance
-
createCosDictionary
public CosDictionary createCosDictionary(int directStatus) throws PDFCosParseException, PDFIOException, PDFSecurityException
Creates an empty COS dictionary. Based on direct status enum, this will be created as either an INDIRECT object (can be referenced and entered in the xref)or as a DIRECT object.- Returns:
- Newly allocated COS dictionary.
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
createCosDictionary
public CosDictionary createCosDictionary() throws PDFCosParseException, PDFIOException, PDFSecurityException
Creates an empty COS dictionary. This will be created as an INDIRECT object (can be referenced and entered in the xref).- Returns:
- Newly allocated COS dictionary.
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
createDirectCosDictionary
public CosDictionary createDirectCosDictionary() throws PDFCosParseException, PDFIOException, PDFSecurityException
Creates an empty COS dictionary. This will be created as a DIRECT object (cannot be referenced or entered in the xref).- Returns:
- Newly allocated COS dictionary.
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
createCosDictionary
public CosDictionary createCosDictionary(java.util.Map cosData, int directStatus) throws PDFCosParseException, PDFIOException, PDFSecurityException
Creates a COS dictionary from a Map of Cos objects based on the value of the directStatus enum.- Parameters:
cosData- Map of Cos objects with ASName keys- Returns:
- Newly allocated COS dictionary.
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
createCosDictionary
public CosDictionary createCosDictionary(java.util.Map cosData) throws PDFCosParseException, PDFIOException, PDFSecurityException
Creates a COS dictionary from a Map of Cos objects. This will be created as an INDIRECT object (can be referenced and entered in the xref).- Parameters:
cosData- Map of Cos objects with ASName keys- Returns:
- Newly allocated COS dictionary.
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
createDirectCosDictionary
public CosDictionary createDirectCosDictionary(java.util.Map cosData) throws PDFCosParseException, PDFIOException, PDFSecurityException
Creates a COS dictionary from a Map of Cos objects. This will be created as a DIRECT object (cannot be referenced or entered in the xref).- Parameters:
cosData- Map of Cos objects with ASName keys- Returns:
- Newly allocated COS dictionary.
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
createCosDictionaryFromNonCosData
public CosDictionary createCosDictionaryFromNonCosData(java.util.Map data, int directStatus) throws PDFCosParseException, PDFIOException, PDFSecurityException
Constructs COS dictionary from the HashMap that contains non-Cos object values. The keys are assumed to be strings and not ASNames. For the values, Boolean gets translated to CosBoolean, Number to CosNumeric, Byte Array to CosString, String to CosName, HashMap to CosDictionary and ArrayList to CosArray. Any other type gets translated to null and is skipped. The strings are converted to ASNames. This uses CosDictionary's put method to insure that the direct object values get the parent dictionary's ID set. Each entry in HashMap and ArrayList gets recursively translated under the same rules.- Parameters:
data- - a Map with string key - non-CosObject value pairs- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
createCosDictionaryFromNonCosData
public CosDictionary createCosDictionaryFromNonCosData(java.util.Map javaMap) throws PDFCosParseException, PDFIOException, PDFSecurityException
Creates a COS dictionary from non CosObject data. Boolean gets translated to CosBoolean, Number to CosNumeric, Byte Array to CosString, String to CosName, HashMap to CosDictionary and ArrayList to CosArray. Any other type gets translated to null and is skipped. Each entry in HashMap and ArrayList gets recursively translated under the same rules. This dictionary will be created as an INDIRECT object (can be referenced and entered in the xref).- Parameters:
javaMap- - Map with strings as keys, nonCos objects as data- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
createDirectCosDictionaryFromNonCosData
public CosDictionary createDirectCosDictionaryFromNonCosData(java.util.Map javaMap) throws PDFCosParseException, PDFIOException, PDFSecurityException
Creates a COS dictionary from non CosObject data. Boolean gets translated to CosBoolean, Number to CosNumeric, Byte Array to CosString, String to CosName, HashMap to CosDictionary and ArrayList to CosArray. Any other type gets translated to null and is skipped. Each entry in HashMap and ArrayList gets recursively translated under the same rules. This dictionary will be created as a DIRECT object (cannot be referenced or entered in the xref).- Parameters:
javaMap- - Map with strings as keys, nonCos objects as data- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
createCosName
public CosName createCosName(ASName value)
Creates a COS name object corresponding to the specified atom.- Parameters:
value- Atom to be wrapped by a COS name object- Returns:
- Newly allocated COS name object.
-
createCosNull
public CosNull createCosNull()
Creates a COS null object.- Returns:
- Newly allocated COS null object.
-
createCosNumeric
public CosNumeric createCosNumeric(java.lang.Number value)
Creates a COS numeric value object.- Parameters:
value- Integer value for the object- Returns:
- Newly allocated COS numeric object initialized with the specified value.
-
createCosNumeric
public CosNumeric createCosNumeric(int value)
Creates a COS numeric value object.- Parameters:
value- Integer value for the object- Returns:
- Newly allocated COS numeric object initialized with the specified value.
-
createCosNumeric
public CosNumeric createCosNumeric(long value)
Creates a COS numeric value object.- Parameters:
value- Integer value for the object- Returns:
- Newly allocated COS numeric object initialized with the specified value.
-
createCosNumeric
public CosNumeric createCosNumeric(double value)
Creates a COS numeric value object.- Parameters:
value- Floating point value for the object- Returns:
- Newly allocated COS numeric object initialized with the specified value.
-
createCosNumeric
public CosNumeric createCosNumeric(byte[] inputRep) throws PDFCosParseException
Creates a COS numeric value object.- Parameters:
inputRep- byte string value for the object- Returns:
- Newly allocated COS numeric object initialized with the specified value.
- Throws:
PDFCosParseException
-
createCosNumeric
public CosNumeric createCosNumeric(CosNumeric source) throws PDFCosParseException, PDFIOException, PDFSecurityException
Creates a COS numeric value object.- Parameters:
source- CosNumeric object to copy- Returns:
- Newly allocated COS numeric object initialized with the specified value.
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
createCosObjectStream
public CosObjectStream createCosObjectStream() throws PDFCosParseException, PDFIOException, PDFSecurityException
Create a new, initialized CosObjectStream instance
-
createCosStream
public CosStream createCosStream() throws PDFCosParseException, PDFIOException, PDFSecurityException
Creates a COS stream with an empty stream data. The filter information must be set in the dictionary portion of the stream before obtaining the output stream that writes into the stream data. CosStreams must always be indirect objects.- Returns:
- newly allocated COS stream.
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
createCosStream
public CosStream createCosStream(InputByteStream data) throws PDFCosParseException, PDFIOException, PDFSecurityException
Creates a CosStream object.- Parameters:
data- Data for the string- Returns:
- Newly allocated CosStream object initialized with the specified data.
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
createCosString
public CosString createCosString(ASString value)
Creates a COS string object.- Parameters:
value- Data for the string- Returns:
- Newly allocated COS string object initialized with the specified data.
-
createCosString
public CosString createCosString(byte[] value)
Creates a COS string object.- Parameters:
value- Data for the string- Returns:
- Newly allocated COS string object initialized with the specified data.
-
createCosString
public CosString createCosString(java.lang.String value)
Creates a COS string object.- Parameters:
value- String. NOTE this String must be in PDFDocEncoding.- Returns:
- Newly allocated COS string object initialized with the specified data.
-
createHexCosString
public CosString createHexCosString(ASString value)
Creates a COS hex string object.- Parameters:
value- Data for the string- Returns:
- Newly allocated COS string object initialized with the specified data.
-
createHexCosString
public CosString createHexCosString(byte[] value)
Creates a COS hex string object.- Parameters:
value- Data for the string- Returns:
- Newly allocated COS string object initialized with the specified data.
-
createHexCosString
public CosString createHexCosString(java.lang.String value)
Creates a COS hex string object.- Parameters:
value- Data for the string- Returns:
- Newly allocated COS string object initialized with the specified data.
-
setUseRepairList
public void setUseRepairList(boolean useRepairList)
For some API's such as PDF/A validation Gibson needs to work on original cos objects and ignore repairs made to cos objects. This flag is set to false for such operations. However this should be reset once that operation is done, so that for further operations on the document repair list cab be used. Default value is true.- Parameters:
useRepairList-
-
-