java.lang.Object
org.sejda.sambox.input.IncrementablePDDocument
- All Implemented Interfaces:
Closeable,AutoCloseable
Model for a document to be used to incrementally update an existing PDF file. Has info regarding PDF objects that
need to be replaced in the original document.
- Author:
- Andrea Vacondio
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()byte[]booleanmodified(COSObjectable modified) Adds the given object as modified, this object will be written as part of the incremental update.voidnewIndirect(COSObjectable newObject) Adds the given object to the set of the new indirect objects.voidreplace(IndirectCOSObjectIdentifier toReplace, COSObjectable replacement) Replaces the object with the givenIndirectCOSObjectIdentifierduring the incremental updatevoidrequireMinVersion(String version) Sets the version for this document if not at the minimum version requiredvoidsetVersion(String newVersion) trailer()voidwriteTo(File file, WriteOption... options) Writes the document to the givenFile.voidwriteTo(OutputStream out, WriteOption... options) Writes the document to the givenOutputStream.voidwriteTo(String filename, WriteOption... options) Writes the document to the file corresponding the given file name.voidwriteTo(WritableByteChannel channel, WriteOption... options) Writes the document to the givenWritableByteChannel.
-
Field Details
-
parser
public final org.sejda.sambox.input.COSParser parser
-
-
Method Details
-
incremented
-
trailer
- Returns:
- the trailer of the incremented document
-
incrementedAsStream
- Returns:
- the incremented document as a stream to be written "as is"
- Throws:
IOException
-
highestExistingReference
- Returns:
- the highest object reference in the document that is being incrementally updated
-
replace
Replaces the object with the givenIndirectCOSObjectIdentifierduring the incremental update- Parameters:
toReplace-replacement-
-
modified
Adds the given object as modified, this object will be written as part of the incremental update.- Parameters:
modified-- Returns:
- true if the
COSBasewas added, false if not. In case where false is returned, theCOSBasedoesn't have an id, meaning it's not written as indirect object in the original document but it's written as direct object. In this case we have to callmodified(COSBase)on the first indirect parent because incremental updates are meant to replace indirect references.
-
newIndirect
Adds the given object to the set of the new indirect objects. These objects will be written as new indirect objects (with a new object number) as part of the incremental update. If, when writing the incremental update, a new object that was not added using this method is found, it will be written as direct object and no indirect reference will be created.- Parameters:
newObject-
-
replacements
- Returns:
- a list of
IndirectCOSObjectReferenceto be written as replacements for this incremental update
-
newIndirects
- Returns:
- a set of objects for which a new indirect reference should be created
-
encryptionDictionary
- Returns:
- the encryption dictionary for the existing document
-
encryptionKey
public byte[] encryptionKey()- Returns:
- the encryption key, if the incremented document is encrypted, null otherwise.
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
writeTo
Writes the document to the givenFile. The document is closed once written.- Parameters:
file-options-- Throws:
IOException
-
writeTo
Writes the document to the file corresponding the given file name. The document is closed once written.- Parameters:
filename-options-- Throws:
IOException
-
writeTo
Writes the document to the givenWritableByteChannel. The document is closed once written.- Parameters:
channel-options-- Throws:
IOException
-
writeTo
Writes the document to the givenOutputStream. The document is closed once written.- Parameters:
out-options-- Throws:
IOException
-
requireMinVersion
Sets the version for this document if not at the minimum version required- Parameters:
version-
-
setVersion
-