public class ExistingPagesSizePredictor extends Object
PDPages and COSObjectables are
added to it. The component does its best to return exact predicted values and it does that by simulating an actual
write, despite that, the predicted values should be considered rough estimations and not a byte precision ones.| Modifier and Type | Method and Description |
|---|---|
void |
addIndirectReferenceFor(COSObjectable value)
Adds the
COSObjectable to the predicted size. |
void |
addPage(PDPage page)
Adds a
PDPage to the predicted size. |
void |
close() |
boolean |
hasPages() |
static ExistingPagesSizePredictor |
instance(WriteOption... opts)
Factory method for an ExistingPagesSizePredictor
|
void |
onPotentialIndirectObject(COSBase item)
Called during the visit on the objects graph, when a potential indirect object is met.
|
long |
pages() |
long |
predictedPagesSize() |
long |
predictedXrefTableSize() |
void |
visit(COSArray array) |
void |
visit(COSDictionary value) |
void |
visit(COSDocument document) |
void |
visit(COSStream value) |
void |
write(COSDocument document)
Writes the body of the given document
|
void |
write(IncrementablePDDocument document)
Writes the given document
|
public void addPage(PDPage page) throws IOException
PDPage to the predicted size. This component simulates the page write to a
DevNullWritableByteChannel and does not release the page objects once written.page - IOExceptionpublic void addIndirectReferenceFor(COSObjectable value) throws IOException
COSObjectable to the predicted size. The object is added as an indirect reference and is
processed, specifically, in case of COSDictionary or COSArray, indirect reference might be
created for their values.value - IOExceptionpublic long predictedPagesSize()
throws IOException
IOExceptionpublic long predictedXrefTableSize()
IOExceptionpublic boolean hasPages()
public long pages()
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic static ExistingPagesSizePredictor instance(WriteOption... opts)
opts - public void write(IncrementablePDDocument document) throws IOException
document - IOExceptionpublic void write(COSDocument document) throws IOException
document - IOExceptionpublic void visit(COSDocument document) throws IOException
visit in interface COSVisitorIOExceptionpublic void visit(COSArray array) throws IOException
visit in interface COSVisitorIOExceptionpublic void visit(COSDictionary value) throws IOException
visit in interface COSVisitorIOExceptionpublic void visit(COSStream value) throws IOException
visit in interface COSVisitorIOExceptionpublic void onPotentialIndirectObject(COSBase item) throws IOException
item - IOExceptionCopyright © 2020 sejda. All rights reserved.