TPdfIccProfileLimits = record
MaxProfileBytes: Int64;
MaxTagCount: Integer;
class function Default: TPdfIccProfileLimits; static;
end;
TPdfIccProfileIssue = (ipiTooLarge, ipiHeaderTruncated, ipiSizeMismatch, ipiSignatureInvalid, ipiUnsupportedColorSpace, ipiTagCountExceeded, ipiTagTableTruncated, ipiTagDataOutOfBounds);
TPdfIccProfileIssues = set of TPdfIccProfileIssue;
TPdfIccProfileInfo = record
Issues: TPdfIccProfileIssues;
ByteSize: Int64;
DeclaredSize: Int64;
Version: string;
VersionBytes: AnsiString;
DeviceClass: string;
DataColorSpace: string;
DataColorSpaceSignature: AnsiString;
Pcs: string;
ComponentCount: Integer;
TagCount: Integer;
Md5: string;
Sha256: string;
ProfileId: string;
ProfileDescription: string;
function IsValid: Boolean;
end;
function InspectPdfIccProfile(const Data: TBytes): TPdfIccProfileInfo;
function InspectPdfIccProfile(const Data: TBytes;
const Limits: TPdfIccProfileLimits): TPdfIccProfileInfo;
function PdfIccProfileDescriptionMatches(const Data: TBytes;
const Expected: string): Boolean;
InspectPdfIccProfile validates the 128-byte header, declared file size, acsp signature, colour-space component count, bounded tag count, tag-table extent and every tag-data range before exposing metadata
The result includes raw four-byte version and colour-space signatures, display values, component and tag counts, profile ID, MD5 of the complete file, SHA-256, device class, PCS and the first valid profile description
GRAY, RGB, CMYK and 2CLR through FCLR signatures are recognised by the general inspector; format-specific validators may impose a narrower process-colour policy
PdfIccProfileDescriptionMatches checks the v2 desc value or every bounded locale record in a v4 mluc profileDescriptionTag
Both description readers confirm the complete mluc record table sits inside its tag and that every selected UTF-16BE text range has an even byte count, starts after the table and remains within it; malformed records neither produce nor match a description
Description text keeps Latin-1 code points and UTF-16 surrogate pairs intact; FPC hands back UTF-8 strings, Delphi Unicode strings
TPdfIccProfileIssue enumerates the individual findings and TPdfIccProfileIssues carries them as a set, so one pass reports every independent deviation at once
TPdfIccProfileLimits carries the run bounds; TPdfIccProfileLimits.Default supplies the values shown in the Limits table, and a negative field disables the corresponding cap
| Limit | Default | Purpose |
|---|---|---|
MaxProfileBytes | 64 MiB | Stops parsing and hashing oversized profiles |
MaxTagCount | 4096 | Stops tag-data traversal once the declared count passes the cap, after header metadata and hashes are collected |
| Value | Reported when |
|---|---|
ipiTooLarge | The profile exceeds MaxProfileBytes, and parsing plus hashing stop before the header is read |
ipiHeaderTruncated | The buffer is shorter than the 128-byte ICC header |
ipiSizeMismatch | The declared size in header bytes 0 through 3 differs from the actual buffer length |
ipiSignatureInvalid | Bytes 36 through 39 are not the acsp signature |
ipiUnsupportedColorSpace | The data colour space is not GRAY, RGB, CMYK, or 2CLR through FCLR |
ipiTagCountExceeded | The tag count read at offset 128 exceeds MaxTagCount |
ipiTagTableTruncated | Fewer than 132 bytes are available or the 12-byte tag table entries extend past the buffer end |
ipiTagDataOutOfBounds | A tag element offset or size reaches past the buffer end or the declared profile size |
| Field | Meaning |
|---|---|
Issues | Set of TPdfIccProfileIssue findings collected during the pass |
ByteSize | Actual length of the supplied profile buffer in bytes |
DeclaredSize | Big-endian 32-bit size claimed in the profile header |
Version | Major, minor, and bugfix version text decoded from header bytes 8 and 9 |
VersionBytes | Raw four header bytes starting at offset 8 kept as an AnsiString |
DeviceClass | Trimmed four-character device class signature from header offset 12 |
DataColorSpace | Trimmed data colour space signature from header offset 16, such as GRAY, RGB, or CMYK |
DataColorSpaceSignature | Raw untrimmed four-byte data colour space signature from header offset 16 |
Pcs | Trimmed profile connection space signature from header offset 20, such as XYZ or Lab |
ComponentCount | Components derived from the data colour space: 1 for GRAY, 3 for RGB, 4 for CMYK, and the value of the leading character for 2CLR through FCLR |
TagCount | Number of tag table entries read from header offset 128 |
Md5 | Lowercase hex MD5 digest of the complete profile bytes |
Sha256 | Lowercase hex SHA-256 digest of the complete profile bytes |
ProfileId | The sixteen profile ID bytes at header offset 84 rendered as lowercase hex |
ProfileDescription | First valid profileDescriptionTag text, read from a v2 desc tag or a bounded locale record of a v4 mluc tag |
TPdfIccProfileInfo.IsValid is True only when the issue set is empty