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 void
close()
Close theCosDocument
and free any resources associated with it.CosArray
createCosArray()
Creates a new, empty COS array object.CosArray
createCosArray(int directStatus)
Creates a new, empty COS array object.CosArray
createCosArray(java.util.ArrayList array)
Creates a new COS array object and populates it with the specified ArrayList of CosObjects.CosArray
createCosArray(java.util.ArrayList array, int directStatus)
Creates a new COS array object and populates it with the specified ArrayList of CosObjects.CosArray
createCosArrayFromNonCosData(java.util.ArrayList array)
Creates a new COS array object and populates it with the specified ArrayList of non CosObjects.CosArray
createCosArrayFromNonCosData(java.util.ArrayList array, int directStatus)
Creates a new COS array object and populates it with the specified ArrayList of non CosObjects.CosBoolean
createCosBoolean(boolean value)
Create a new CosBoolean instance (always a direct object)CosBoolean
createCosBoolean(java.lang.Boolean value)
Create a new CosBoolean instance (always a direct object)CosDictionary
createCosDictionary()
Creates an empty COS dictionary.CosDictionary
createCosDictionary(int directStatus)
Creates an empty COS dictionary.CosDictionary
createCosDictionary(java.util.Map cosData)
Creates a COS dictionary from a Map of Cos objects.CosDictionary
createCosDictionary(java.util.Map cosData, int directStatus)
Creates a COS dictionary from a Map of Cos objects based on the value of the directStatus enum.CosDictionary
createCosDictionaryFromNonCosData(java.util.Map javaMap)
Creates a COS dictionary from non CosObject data.CosDictionary
createCosDictionaryFromNonCosData(java.util.Map data, int directStatus)
Constructs COS dictionary from the HashMap that contains non-Cos object values.CosName
createCosName(ASName value)
Creates a COS name object corresponding to the specified atom.CosNull
createCosNull()
Creates a COS null object.CosNumeric
createCosNumeric(byte[] inputRep)
Creates a COS numeric value object.CosNumeric
createCosNumeric(double value)
Creates a COS numeric value object.CosNumeric
createCosNumeric(int value)
Creates a COS numeric value object.CosNumeric
createCosNumeric(long value)
Creates a COS numeric value object.CosNumeric
createCosNumeric(CosNumeric source)
Creates a COS numeric value object.CosNumeric
createCosNumeric(java.lang.Number value)
Creates a COS numeric value object.CosObjectStream
createCosObjectStream()
Create a new, initialized CosObjectStream instanceCosStream
createCosStream()
Creates a COS stream with an empty stream data.CosStream
createCosStream(InputByteStream data)
Creates a CosStream object.CosString
createCosString(byte[] value)
Creates a COS string object.CosString
createCosString(ASString value)
Creates a COS string object.CosString
createCosString(java.lang.String value)
Creates a COS string object.CosDictionary
createDirectCosDictionary()
Creates an empty COS dictionary.CosDictionary
createDirectCosDictionary(java.util.Map cosData)
Creates a COS dictionary from a Map of Cos objects.CosDictionary
createDirectCosDictionaryFromNonCosData(java.util.Map javaMap)
Creates a COS dictionary from non CosObject data.CosString
createHexCosString(byte[] value)
Creates a COS hex string object.CosString
createHexCosString(ASString value)
Creates a COS hex string object.CosString
createHexCosString(java.lang.String value)
Creates a COS hex string object.CosArray
createIndirectCosArray()
Creates a new, empty COS array object.CosArray
createIndirectCosArray(java.util.ArrayList array)
Creates a new COS array object and populates it with the specified ArrayList of CosObjects.CosArray
createIndirectCosArrayFromNonCosData(java.util.ArrayList array)
Creates a new COS array object and populates it with the specified ArrayList of non CosObjects.PDFCore
finish()
void
freeDuplicateResources()
Parse the document to identify and remove duplicate resources referenced in the page resource object trees.boolean
freeUnreferencedObjects()
Explicit early cleanup of unreferenced objects as done in full save.ByteReader
getByteReader()
CosList
getChangedObjects(long eof)
Return CosLIst of objects added, deleted, or changed since EOF value.CosEncryption
getEncryption()
long
getEOF()
java.lang.Object
getFdfDocument()
Returns pointer to FDFDocumentlong
getFileSize()
int
getHeaderTrashCount()
Return the count of trash bytes that appear before the document header.CosObject
getIndirectObjectByNumber(int objNum)
Return an indirect CosObject instance corresponding to an object number.CosObjectInfo
getIndirectObjectInfoByNumber(int objNum)
Return an indirect CosObjectInfo instance corresponding to an object number.CosDictionary
getInfo()
Retrieves the Information CosDictionary of the document, may be null.ByteWriter
getInPlaceByteWriter()
static java.lang.String
getLoggingPath()
int
getNumObjects()
int
getNumRevisions()
Get total number of revisions for this document.long
getObjEOF(CosObject obj)
Return EOF of object's update section or zero if cannot be determined.int
getObjRevision(CosObject obj)
Return index of object's update section or -1 if cannot be determined.CosOpenOptions
getOptions()
java.lang.String
getOriginalVersion()
Returns the version string of the PDF file (e.g.java.lang.Object
getPdfDocument()
Gets pointer to PDFDocumentjava.util.EnumSet<REPAIRTYPE>
getRepairTypes()
CosDictionary
getRoot()
Retrieves the root CosDictionary of the document if it's not already cached; otherwise, returns the cached root.InputByteStream
getStream()
Obtain a slice of the underlying InputByteStream for the document.InputByteStream
getStream(long start, long length)
Obtain a slice of the underlying InputByteStream for the document.StreamManager
getStreamManager()
Get theStreamManager
to use for this document.java.util.Map
getToSaveExtensions()
java.lang.String
getToSaveVersion()
CosDictionary
getTrailer()
Retrieves the trailer from the document.CosDictionary[]
getTrailerList()
int
getTrailerTrashCount()
Return the count of trash bytes that appear after the document trailer.CosObject[]
getUnreferencedObjects()
Return an array of unreferenced indirect objects in this document.int
getXRefType()
Get the current XRef typeboolean
isCacheEnabled()
boolean
isDirty()
Is the document dirty?boolean
isEncrypted()
boolean
isLinearized()
Returns true iff the document is currently linearized.boolean
isToSaveExtensionsInitialized()
void
markDirty()
boolean
markNotDirty()
Mark document as not dirty.static CosDocument
newDocument(ByteReader byteReader, CosOpenOptions options)
Returns an empty document with some initialized data structures so that you can build a new CosDocument.static CosDocument
newDocument(CosOpenOptions options)
Returns an empty document with some initialized data structures so that you can build a new CosDocument.static CosDocument
newDocument(PDFCore pdfCore)
Once a CosDocument was instanciated from a PDFCore object, that PDFCore object can't be used again.java.lang.String
procureOriginalVersion()
java.lang.String
procureToSaveVersion()
void
save(ByteWriter byteWriter, CosSaveParams params)
Perform an save with previously specified save stylevoid
setFDFDocument(java.lang.Object fdfDocument)
Sets pointer to FDFDocumentstatic void
setLoggingPath(java.lang.String loggingPath)
void
setNextIncrementalSectionOffset(long nextIncrementalSectionOffset)
Sets the offset where next incremental section shall be written if the document is saved incrementally.void
setPDFDocument(java.lang.Object pdfdocument)
Sets pointer to PDFDocumentvoid
setToSaveExtensions(java.util.Map extensions)
void
setToSaveVersion(java.lang.String version)
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.boolean
wasLinearized()
Returns true iff the BASE document was a linearized document, but later suffered incremental updates that spoil its perfect order.boolean
wasRepaired()
-
-
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
getStreamManager
public StreamManager getStreamManager()
Get theStreamManager
to 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, PDFSecurityException
Close theCosDocument
and free any resources associated with it.
-
getOriginalVersion
public java.lang.String getOriginalVersion() throws PDFCosParseException, PDFIOException, PDFSecurityException
Returns 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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
getInfo
public CosDictionary getInfo() throws PDFCosParseException, PDFIOException, PDFSecurityException
Retrieves the Information CosDictionary of the document, may be null.- Returns:
- Document's Information dictionary
- Throws:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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
'sInputByteStream
to 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, PDFSecurityException
Parse 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, PDFSecurityException
Explicit 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:
PDFCosParseException
PDFInvalidParameterException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
true
if the document is dirty;false
otherwise
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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:
PDFCosParseException
PDFIOException
PDFSecurityException
-
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
-
-
-