Table of Contents

Class PdfResourceCounter

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

This class can be used to count the number of bytes needed when copying pages from an existing PDF into a newly created PDF.

public class PdfResourceCounter
Inheritance
PdfResourceCounter
Inherited Members

Constructors

PdfResourceCounter(PdfObject)

Creates a PdfResourceCounter instance to be used to count the resources needed for either a page (in this case pass a page dictionary) or the trailer (root and info dictionary) of a PDF file.

public PdfResourceCounter(PdfObject obj)

Parameters

obj PdfObject

the object we want to examine

Methods

GetLength(IDictionary<int, PdfObject>)

Returns the resources needed for the object that was used to create this PdfResourceCounter.

public virtual long GetLength(IDictionary<int, PdfObject> res)

Parameters

res IDictionary<int, PdfObject>

The resources that can be excluded when counting the bytes.

Returns

long

The number of bytes needed for an object.

Remarks

Returns the resources needed for the object that was used to create this PdfResourceCounter. If you pass a Map with resources that were already used by other objects, these objects will not be taken into account.

GetResources()

Returns a map with the resources.

public virtual IDictionary<int, PdfObject> GetResources()

Returns

IDictionary<int, PdfObject>

the resources

LoopOver(PdfObject)

In case an object is an array, a dictionary or a stream, we need to loop over the entries and process them one by one.

protected void LoopOver(PdfObject obj)

Parameters

obj PdfObject

the object to examine

Process(PdfObject)

Processes an object.

protected void Process(PdfObject obj)

Parameters

obj PdfObject

the object to process

Remarks

Processes an object. If the object is indirect, it is added to the list of resources. If not, it is just processed.