CPDFDocumentMemoryDistribution Class Reference
| Inherits from | NSObject |
|---|---|
| Declared in | CPDFDocumentMemoryDistribution.h |
Overview
CPDFDocumentMemoryDistribution provides statistics on the memory/space distribution of different element categories within a PDF document.
Use this class to analyze how much space each type of element (images, fonts, annotations, etc.) occupies in a PDF file. This is particularly useful for understanding document composition before performing optimization/compression operations.
@code CPDFDocumentMemoryDistribution *distribution = [[CPDFDocumentMemoryDistribution alloc] initWithFilePath:@“/path/to/file.pdf” password:nil]; if (distribution) { uint32_t totalSize = [distribution totalSize]; uint32_t imageSize = [distribution sizeForCategory:CPDFMemoryDistributionCategoryImage]; CPDFDocumentElementSize elementSize = [distribution elementSize]; // Use elementSize.imageSize, elementSize.fontSize, etc. } @endcode
– initWithFilePath:password:
Initializes a memory distribution analysis for the PDF file at the given path.
- (nullable instancetype)initWithFilePath:(nonnull NSString *)filePath password:(nullable NSString *)passwordParameters
filePath |
The file path to the PDF document. |
|---|---|
password |
The password for opening encrypted documents; pass nil if not needed. |
Return Value
An initialized CPDFDocumentMemoryDistribution instance, or nil if initialization fails.
Discussion
Initializes a memory distribution analysis for the PDF file at the given path.
Declared In
CPDFDocumentMemoryDistribution.h
– initWithURL:password:
Initializes a memory distribution analysis for the PDF document at the given URL.
- (nullable instancetype)initWithURL:(nonnull NSURL *)url password:(nullable NSString *)passwordParameters
url |
The file URL to the PDF document. |
|---|---|
password |
The password for opening encrypted documents; pass nil if not needed. |
Return Value
An initialized CPDFDocumentMemoryDistribution instance, or nil if initialization fails.
Discussion
Initializes a memory distribution analysis for the PDF document at the given URL.
Declared In
CPDFDocumentMemoryDistribution.h
– elementSize
Returns the complete element size distribution as a structure.
- (CPDFDocumentElementSize)elementSizeReturn Value
A CPDFDocumentElementSize structure containing the sizes of all element categories.
Discussion
Returns the complete element size distribution as a structure.
Declared In
CPDFDocumentMemoryDistribution.h
– totalSize
Returns the total document size in bytes.
- (uint32_t)totalSizeReturn Value
The total size of the document in bytes.
Discussion
Returns the total document size in bytes.
Declared In
CPDFDocumentMemoryDistribution.h
– sizeForCategory:
Returns the size (in bytes) for the specified element category.
- (uint32_t)sizeForCategory:(CPDFMemoryDistributionCategory)categoryParameters
category |
The category to query. |
|---|
Return Value
The size in bytes for the given category.
Discussion
Returns the size (in bytes) for the specified element category.
Declared In
CPDFDocumentMemoryDistribution.h