PDFium Delphi Component Docs

FPdfIccProfile unit

Unit: FPdfIccProfile
Bounded ICC profile header and tag-table inspection for standards validation and production evidence

Syntax

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;

Description

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

Limits

LimitDefaultPurpose
MaxProfileBytes64 MiBStops parsing and hashing oversized profiles
MaxTagCount4096Stops tag-data traversal once the declared count passes the cap, after header metadata and hashes are collected

Inspection issues

ValueReported when
ipiTooLargeThe profile exceeds MaxProfileBytes, and parsing plus hashing stop before the header is read
ipiHeaderTruncatedThe buffer is shorter than the 128-byte ICC header
ipiSizeMismatchThe declared size in header bytes 0 through 3 differs from the actual buffer length
ipiSignatureInvalidBytes 36 through 39 are not the acsp signature
ipiUnsupportedColorSpaceThe data colour space is not GRAY, RGB, CMYK, or 2CLR through FCLR
ipiTagCountExceededThe tag count read at offset 128 exceeds MaxTagCount
ipiTagTableTruncatedFewer than 132 bytes are available or the 12-byte tag table entries extend past the buffer end
ipiTagDataOutOfBoundsA tag element offset or size reaches past the buffer end or the declared profile size

Info fields

FieldMeaning
IssuesSet of TPdfIccProfileIssue findings collected during the pass
ByteSizeActual length of the supplied profile buffer in bytes
DeclaredSizeBig-endian 32-bit size claimed in the profile header
VersionMajor, minor, and bugfix version text decoded from header bytes 8 and 9
VersionBytesRaw four header bytes starting at offset 8 kept as an AnsiString
DeviceClassTrimmed four-character device class signature from header offset 12
DataColorSpaceTrimmed data colour space signature from header offset 16, such as GRAY, RGB, or CMYK
DataColorSpaceSignatureRaw untrimmed four-byte data colour space signature from header offset 16
PcsTrimmed profile connection space signature from header offset 20, such as XYZ or Lab
ComponentCountComponents 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
TagCountNumber of tag table entries read from header offset 128
Md5Lowercase hex MD5 digest of the complete profile bytes
Sha256Lowercase hex SHA-256 digest of the complete profile bytes
ProfileIdThe sixteen profile ID bytes at header offset 84 rendered as lowercase hex
ProfileDescriptionFirst valid profileDescriptionTag text, read from a v2 desc tag or a bounded locale record of a v4 mluc tag

Remarks

See Also

FPdfPdfvtMime