public class MemoryLimitsAwareHandler extends Object
MemoryLimitsAwareHandler handles memory allocation and prevents decompressed
pdf streams from occupation of more space than allowed.
A configured MemoryLimitsAwareHandler can be set as a property of ReaderProperties
instance which is passed to PdfReader.
| Constructor and Description |
|---|
MemoryLimitsAwareHandler()
Creates a
MemoryLimitsAwareHandler which will be used to handle decompression of pdf streams. |
MemoryLimitsAwareHandler(long documentSize)
Creates a
MemoryLimitsAwareHandler which will be used to handle decompression of pdf streams. |
| Modifier and Type | Method and Description |
|---|---|
protected static int |
calculateMaxElementsInXref(long documentSizeInBytes)
Calculate max number of elements allowed in xref table based on the size of the document, achieving max limit at 100MB.
|
void |
checkIfPageSizeExceedsTheLimit(long totalXObjectsSize) |
void |
checkIfXrefStructureExceedsTheLimit(int requestedCapacity)
Performs a check of possible extension of xref structure.
|
MemoryLimitsAwareHandler |
createNewInstance()
Creates a new instance of
MemoryLimitsAwareHandler by copying settings from this instance
of MemoryLimitsAwareHandler. |
int |
getMaxNumberOfElementsInXrefStructure()
Gets maximum number of elements in xref structure.
|
long |
getMaxSizeOfDecompressedPdfStreamsSum()
Gets the maximum allowed size which can be occupied by all decompressed pdf streams.
|
int |
getMaxSizeOfSingleDecompressedPdfStream()
Gets the maximum allowed size which can be occupied by a single decompressed pdf stream.
|
long |
getMaxXObjectsSizePerPage()
Gets maximum page size.
|
boolean |
isMemoryLimitsAwarenessRequiredOnDecompression(PdfArray filters)
Performs a check if the
PdfStream with provided setup of the filters requires
memory limits awareness during decompression. |
void |
setMaxNumberOfElementsInXrefStructure(int maxNumberOfElementsInXrefStructure)
Sets maximum number of elements in xref structure.
|
MemoryLimitsAwareHandler |
setMaxSizeOfDecompressedPdfStreamsSum(long maxSizeOfDecompressedPdfStreamsSum)
Sets the maximum allowed size which can be occupied by all decompressed pdf streams.
|
MemoryLimitsAwareHandler |
setMaxSizeOfSingleDecompressedPdfStream(int maxSizeOfSingleDecompressedPdfStream)
Sets the maximum allowed size which can be occupied by a single decompressed pdf stream.
|
void |
setMaxXObjectsSizePerPage(long maxPageSize)
Sets maximum page size.
|
public MemoryLimitsAwareHandler()
MemoryLimitsAwareHandler which will be used to handle decompression of pdf streams.
The max allowed memory limits will be generated by default.public MemoryLimitsAwareHandler(long documentSize)
MemoryLimitsAwareHandler which will be used to handle decompression of pdf streams.
The max allowed memory limits will be generated by default, based on the size of the document.documentSize - the size of the document, which is going to be handled by iText.public MemoryLimitsAwareHandler createNewInstance()
MemoryLimitsAwareHandler by copying settings from this instance
of MemoryLimitsAwareHandler.MemoryLimitsAwareHandler.public int getMaxSizeOfSingleDecompressedPdfStream()
public MemoryLimitsAwareHandler setMaxSizeOfSingleDecompressedPdfStream(int maxSizeOfSingleDecompressedPdfStream)
iText will throw an exception if during decompression a pdf stream which was identified as requiring memory limits awareness occupies more memory than allowed.
maxSizeOfSingleDecompressedPdfStream - the maximum allowed size which can be occupied by a single
decompressed pdf stream.MemoryLimitsAwareHandler instance.isMemoryLimitsAwarenessRequiredOnDecompression(PdfArray)public long getMaxSizeOfDecompressedPdfStreamsSum()
public MemoryLimitsAwareHandler setMaxSizeOfDecompressedPdfStreamsSum(long maxSizeOfDecompressedPdfStreamsSum)
iText will throw an exception if during decompression pdf streams which were identified as requiring memory limits awareness occupy more memory than allowed.
maxSizeOfDecompressedPdfStreamsSum - he maximum allowed size which can be occupied by all decompressed pdf
streams.MemoryLimitsAwareHandler instance.isMemoryLimitsAwarenessRequiredOnDecompression(PdfArray)public boolean isMemoryLimitsAwarenessRequiredOnDecompression(PdfArray filters)
PdfStream with provided setup of the filters requires
memory limits awareness during decompression.filters - is an PdfArray of names of filterspublic int getMaxNumberOfElementsInXrefStructure()
public long getMaxXObjectsSizePerPage()
public void setMaxXObjectsSizePerPage(long maxPageSize)
maxPageSize - maximum page size.public void setMaxNumberOfElementsInXrefStructure(int maxNumberOfElementsInXrefStructure)
maxNumberOfElementsInXrefStructure - maximum number of elements in xref structure.public void checkIfXrefStructureExceedsTheLimit(int requestedCapacity)
requestedCapacity - capacity to which we need to expand xref array.public void checkIfPageSizeExceedsTheLimit(long totalXObjectsSize)
protected static int calculateMaxElementsInXref(long documentSizeInBytes)
documentSizeInBytes - document size in bytes.Copyright © 1998–2024 Apryse Group NV. All rights reserved.