Table of Contents

Class MemoryLimitsAwareHandler

Namespace
iText.Kernel.Pdf
Assembly
itext.kernel.dll

A MemoryLimitsAwareHandler handles memory allocation and prevents decompressed pdf streams from occupation of more space than allowed.

public class MemoryLimitsAwareHandler
Inheritance
MemoryLimitsAwareHandler
Inherited Members

Remarks

A 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.

Constructors

MemoryLimitsAwareHandler()

Creates a MemoryLimitsAwareHandler which will be used to handle decompression of pdf streams.

public MemoryLimitsAwareHandler()

Remarks

Creates a MemoryLimitsAwareHandler which will be used to handle decompression of pdf streams. The max allowed memory limits will be generated by default.

See Also

MemoryLimitsAwareHandler(long)

Creates a MemoryLimitsAwareHandler which will be used to handle decompression of pdf streams.

public MemoryLimitsAwareHandler(long documentSize)

Parameters

documentSize long

the size of the document, which is going to be handled by iText.

Remarks

Creates a 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.

See Also

Methods

CalculateMaxElementsInXref(long)

Calculate max number of elements allowed in xref table based on the size of the document, achieving max limit at 100MB.

protected static int CalculateMaxElementsInXref(long documentSizeInBytes)

Parameters

documentSizeInBytes long

document size in bytes.

Returns

int

calculated limit.

See Also

CheckIfPageSizeExceedsTheLimit(long)

public virtual void CheckIfPageSizeExceedsTheLimit(long totalXObjectsSize)

Parameters

totalXObjectsSize long
See Also

CheckIfXrefStructureExceedsTheLimit(int)

Performs a check of possible extension of xref structure.

public virtual void CheckIfXrefStructureExceedsTheLimit(int requestedCapacity)

Parameters

requestedCapacity int

capacity to which we need to expand xref array.

See Also

GetMaxNumberOfElementsInXrefStructure()

Gets maximum number of elements in xref structure.

public virtual int GetMaxNumberOfElementsInXrefStructure()

Returns

int

maximum number of elements in xref structure.

See Also

GetMaxSizeOfDecompressedPdfStreamsSum()

Gets the maximum allowed size which can be occupied by all decompressed pdf streams.

public virtual long GetMaxSizeOfDecompressedPdfStreamsSum()

Returns

long

the maximum allowed size value which streams may occupy

See Also

GetMaxSizeOfSingleDecompressedPdfStream()

Gets the maximum allowed size which can be occupied by a single decompressed pdf stream.

public virtual int GetMaxSizeOfSingleDecompressedPdfStream()

Returns

int

the maximum allowed size which can be occupied by a single decompressed pdf stream.

See Also

GetMaxXObjectsSizePerPage()

Gets maximum page size.

public virtual long GetMaxXObjectsSizePerPage()

Returns

long

maximum page size.

See Also

IsMemoryLimitsAwarenessRequiredOnDecompression(PdfArray)

Performs a check if the PdfStream with provided setup of the filters requires memory limits awareness during decompression.

public virtual bool IsMemoryLimitsAwarenessRequiredOnDecompression(PdfArray filters)

Parameters

filters PdfArray

is an PdfArray of names of filters

Returns

bool

true if PDF stream is suspicious and false otherwise

See Also

SetMaxNumberOfElementsInXrefStructure(int)

Sets maximum number of elements in xref structure.

public virtual void SetMaxNumberOfElementsInXrefStructure(int maxNumberOfElementsInXrefStructure)

Parameters

maxNumberOfElementsInXrefStructure int

maximum number of elements in xref structure.

See Also

SetMaxSizeOfDecompressedPdfStreamsSum(long)

Sets the maximum allowed size which can be occupied by all decompressed pdf streams.

public virtual MemoryLimitsAwareHandler SetMaxSizeOfDecompressedPdfStreamsSum(long maxSizeOfDecompressedPdfStreamsSum)

Parameters

maxSizeOfDecompressedPdfStreamsSum long

he maximum allowed size which can be occupied by all decompressed pdf streams.

Returns

MemoryLimitsAwareHandler

this MemoryLimitsAwareHandler instance.

Remarks

Sets the maximum allowed size which can be occupied by all decompressed pdf streams. This value can be limited by the maximum expected PDF file size when it's completely decompressed. Setting this value correlates with the maximum processing time spent on document reading

iText will throw an exception if during decompression pdf streams which were identified as requiring memory limits awareness occupy more memory than allowed.
See Also

SetMaxSizeOfSingleDecompressedPdfStream(int)

Sets the maximum allowed size which can be occupied by a single decompressed pdf stream.

public virtual MemoryLimitsAwareHandler SetMaxSizeOfSingleDecompressedPdfStream(int maxSizeOfSingleDecompressedPdfStream)

Parameters

maxSizeOfSingleDecompressedPdfStream int

the maximum allowed size which can be occupied by a single decompressed pdf stream.

Returns

MemoryLimitsAwareHandler

this MemoryLimitsAwareHandler instance.

Remarks

Sets the maximum allowed size which can be occupied by a single decompressed pdf stream. This value correlates with maximum heap size. This value should not exceed limit of the heap size.

iText will throw an exception if during decompression a pdf stream which was identified as requiring memory limits awareness occupies more memory than allowed.
See Also

SetMaxXObjectsSizePerPage(long)

Sets maximum page size.

public virtual void SetMaxXObjectsSizePerPage(long maxPageSize)

Parameters

maxPageSize long

maximum page size.

See Also

See Also