Package com.itextpdf.kernel.utils
Class PdfResourceCounter
java.lang.Object
com.itextpdf.kernel.utils.PdfResourceCounter
This class can be used to count the number of bytes needed when copying pages from an existing PDF into a newly created PDF.
-
Constructor Summary
ConstructorDescriptionCreates 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. -
Method Summary
Modifier and TypeMethodDescriptionlong
Returns the resources needed for the object that was used to create this PdfResourceCounter.Returns a map with the resources.protected final void
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 final void
Processes an object.
-
Constructor Details
-
PdfResourceCounter
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.- Parameters:
-
obj
- the object we want to examine
-
-
Method Details
-
process
Processes an object. If the object is indirect, it is added to the list of resources. If not, it is just processed.- Parameters:
-
obj
- the object to process
-
loopOver
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.- Parameters:
-
obj
- the object to examine
-
getResources
Returns a map with the resources.- Returns:
- the resources
-
getLength
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.- Parameters:
-
res
- The resources that can be excluded when counting the bytes. - Returns:
- The number of bytes needed for an object.
-