PDFium Delphi Component Docs

FPdfIccProfile 單元

單元: FPdfIccProfile
用於標準驗證與生產證據的有界 ICC 描述檔檔頭與標籤表檢查

語法

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 在公開中繼資料之前,會驗證 128 位元組檔頭、宣告的檔案大小、acsp 簽章、色彩空間元件數、有界的標籤數、標籤表範圍,以及每個標籤資料範圍

結果包含原始四位元組版本與色彩空間簽章、顯示值、元件與標籤計數、描述檔 ID、整個檔案的 MD5、SHA-256、裝置類別、PCS,以及第一個有效的描述檔描述

通用檢查器可識別 GRAY、RGB、CMYK 與 2CLR 到 FCLR 的簽章;格式專屬驗證器可能施加更嚴格的印刷色彩政策

PdfIccProfileDescriptionMatches 會檢查 v2 desc 值,或 v4 mluc profileDescriptionTag 中的每個有界地區設定記錄

兩個描述讀取器都會檢查完整的 mluc 記錄表落在其標籤內,且每個選取的 UTF-16BE 文字範圍具有偶數位元組數、起始於表格之後並停留在標籤內;格式錯誤的記錄不會產生或比對出描述

描述文字保留 Latin-1 碼位與 UTF-16 代理對;FPC 傳回 UTF-8 字串,Delphi 則傳回 Unicode 字串

TPdfIccProfileIssue 列舉各項發現,TPdfIccProfileIssues 以集合攜帶它們,因此單次檢查即可同時回報所有獨立的偏差

TPdfIccProfileLimits 攜帶執行範圍;TPdfIccProfileLimits.Default 提供限制表格中的預設值,負值欄位則停用對應上限

限制

LimitDefaultPurpose
MaxProfileBytes64 MiB停止解析與雜湊超過大小的描述檔
MaxTagCount4096限制標籤表走訪範圍

檢查問題

ValueReported when
ipiTooLarge描述檔超過 MaxProfileBytes,解析與雜湊在讀取檔頭之前即停止
ipiHeaderTruncated緩衝區短於 128 位元組的 ICC 檔頭
ipiSizeMismatch檔頭位元組 0 到 3 宣告的大小與實際緩衝區長度不一致
ipiSignatureInvalid位元組 36 到 39 不是 acsp 簽章
ipiUnsupportedColorSpace資料色彩空間不是 GRAY、RGB、CMYK 或 2CLR 到 FCLR
ipiTagCountExceeded在位移 128 讀到的標籤數超過 MaxTagCount
ipiTagTableTruncated可用位元組少於 132,或 12 位元組的標籤表條目延伸超出緩衝區結尾
ipiTagDataOutOfBounds標籤元素位移或大小超出緩衝區結尾或宣告的描述檔大小

資訊欄位

FieldMeaning
Issues單次檢查期間收集的 TPdfIccProfileIssue 發現集合
ByteSize提供的描述檔緩衝區實際長度(位元組)
DeclaredSize描述檔檔頭宣告的 big-endian 32 位元大小
Version從檔頭位元組 8 與 9 解碼出的主要、次要與修訂版本文字
VersionBytes自位移 8 起的原始四個檔頭位元組,保留為 AnsiString
DeviceClass從檔頭位移 12 取得的已修剪四字元裝置類別簽章
DataColorSpace從檔頭位移 16 取得的已修剪資料色彩空間簽章,例如 GRAY、RGB 或 CMYK
DataColorSpaceSignature從檔頭位移 16 取得的原始未修剪四位元組資料色彩空間簽章
Pcs從檔頭位移 20 取得的已修剪 profile connection space 簽章,例如 XYZ 或 Lab
ComponentCount由資料色彩空間推導的分量數:GRAY 為 1、RGB 為 3、CMYK 為 4,2CLR 到 FCLR 則為首字元的數值
TagCount從檔頭位移 128 讀到的標籤表條目數
Md5完整描述檔位元組的小寫十六進位 MD5 摘要
Sha256完整描述檔位元組的小寫十六進位 SHA-256 摘要
ProfileId檔頭位移 84 的十六個描述檔 ID 位元組,以小寫十六進位呈現
ProfileDescription第一個有效的 profileDescriptionTag 文字,讀自 v2 desc 標籤或 v4 mluc 標籤的有界地區設定記錄

備註

另請參閱

FPdfPdfvtMime