PDFium Delphi Component Docs

FPdfCompress 單元

單元: FPdfCompress
TPdf 儲存管線使用的串流層級 PDF 重寫、壓縮、內容正規化、選用內容組態、清理、物件圖存取、增量修訂與版本檢查

說明

FPdfCompress 包含 PDFium 序列化文件之後使用的公開串流轉換器,以及為每個轉換器設定選項並回報結果的記錄

完整重寫輔助函式會具體化作用中的物件圖,保留或刻意重建交叉參照,並拒絕無法安全重寫的輸入;以報告為基礎的程序會透過 Succeeded 與 ErrorMessage 回傳失敗

大多數應用程式會使用對應的 TPdf 儲存、檢查或物件圖方法,而本單元程序仍可供已擁有序列化 PDF 串流的呼叫端使用

語法

TPdfTreeEditor = class
  class function TryLoad(Source: TStream; Kind: TPdfTreeKind;
    const RootReference: TPdfTreeObjectReference;
    const Options: TPdfTreeEditOptions; out Editor: TPdfTreeEditor;
    out Report: TPdfTreeValidationReport): Boolean; static;
  class function Load(Source: TStream; Kind: TPdfTreeKind;
    const RootReference: TPdfTreeObjectReference;
    const Options: TPdfTreeEditOptions): TPdfTreeEditor; static;
  function UpsertName(const Key, RawValue: AnsiString): Boolean;
  function UpsertNumber(Key: Int64; const RawValue: AnsiString): Boolean;
  function RemoveName(const Key: AnsiString): Boolean;
  function RemoveNumber(Key: Int64): Boolean;
  procedure Clear;
  function Validate(out Report: TPdfTreeValidationReport): Boolean;
  function BuildBalancedObjects(out Objects: TPdfTreeSerializedObjects;
    out Report: TPdfTreeValidationReport): Boolean;
  function SaveIncremental(Source, Dest: TStream;
    out Report: TPdfTreeValidationReport): Boolean;
  property Count: Integer;
  property Entries[Index: Integer]: TPdfTreeEntry; default;
end;
TPdfOutlineEditor = class
  class function TryLoad(Source: TStream;
    const Options: TPdfOutlineEditOptions; out Editor: TPdfOutlineEditor;
    out Report: TPdfOutlineValidationReport): Boolean; static;
  class function Load(Source: TStream;
    const Options: TPdfOutlineEditOptions): TPdfOutlineEditor; static;
  function Add(ParentId, SiblingIndex: Integer; const Title: WideString;
    PageNumber: Integer): Integer;
  function Delete(Id: Integer): Boolean;
  function Move(Id, NewParentId, SiblingIndex: Integer): Boolean;
  procedure SetTitle(Id: Integer; const Title: WideString);
  procedure SetStyle(Id: Integer; const Style: TPdfOutlineStyle);
  procedure SetExpanded(Id: Integer; Expanded: Boolean);
  procedure SetColor(Id: Integer; Red, Green, Blue: Single);
  procedure ClearColor(Id: Integer);
  procedure Retarget(Id, PageNumber: Integer;
    const DestinationSuffix: AnsiString = '/Fit';
    DestinationInAction: Boolean = False);
  function ApplyPageMap(const NewPageNumbers: array of Integer;
    DeleteDangling: Boolean; out Report: TPdfOutlineValidationReport): Boolean;
  function Validate(out Report: TPdfOutlineValidationReport): Boolean;
  function SaveIncremental(Source, Dest: TStream;
    out Report: TPdfOutlineValidationReport): Boolean;
  property Count: Integer;
  property Items[Index: Integer]: TPdfOutlineItem; default;
end;
TPdfCrossDocumentGraftMap = class
  constructor Create(const SourceIdentity: AnsiString);
  procedure Clear;
  function TryResolve(const Source: TPdfGraftObjectReference;
    out Destination: TPdfGraftObjectReference): Boolean;
  procedure Add(const Source, Destination: TPdfGraftObjectReference);
  property Count: Integer;
  property Entries[Index: Integer]: TPdfGraftMapEntry; default;
  property SourceIdentity: AnsiString;
end;
TPdfSparseDictionaryReader = class
  constructor Create(Source: TStream);
  function ReadDictionary(ObjectNumber, Generation: Integer;
    out Dictionary: AnsiString): Boolean;
  function ReadLatestDictionary(ObjectNumber: Integer;
    out Generation: Integer; out Dictionary: AnsiString): Boolean;
  function ReadDecodedStream(ObjectNumber, Generation,
    MaximumDecodedBytes: Integer; out Data: TBytes): Boolean;
  property Valid: Boolean;
end;
procedure CompressPdfStream(Source, Dest: TStream);
procedure LinearizePdfStream(Source, Dest: TStream);
procedure PackPdfObjectStreams(Source, Dest: TStream;
  MaxObjectsPerStream: Integer = 100;
  MaxDecodedBytesPerStream: Integer = 65536);
procedure NormalizePdfDocumentContent(Source, Dest: TStream;
  const Options: TPdfContentNormalizeOptions;
  out Report: TPdfContentNormalizeReport);
function GraftPdfAcroForm(Source, Destination, Output: TStream;
  const PageMappings: TPdfGraftPageMappings;
  const Options: TPdfAcroFormGraftOptions;
  GraftMap: TPdfCrossDocumentGraftMap;
  out Report: TPdfAcroFormGraftReport): Boolean;
procedure PruneUnreachablePdfStream(Source, Dest: TStream;
  out Report: TPdfPruneReport);
procedure PruneUnusedPdfResources(Source, Dest: TStream;
  out Report: TPdfResourcePruneReport;
  AllowSignedDocument: Boolean = False);
procedure DeduplicateResourcesPdfStream(Source, Dest: TStream;
  out Report: TPdfDedupReport);
procedure RecompressFlatePdfStream(Source, Dest: TStream;
  const Options: TPdfFlateRecompressOptions;
  out Report: TPdfFlateRecompressReport);
procedure ExternaliseInlineImagesPdfStream(Source, Dest: TStream;
  const Options: TPdfInlineImageExternaliseOptions;
  out Report: TPdfInlineImageExternaliseReport);
procedure ReproduciblePdfStream(Source, Dest: TStream;
  out Report: TPdfReproducibleReport);
procedure AppendPdfDirtyRevision(BaselineState, CurrentState,
  PreviousOutput, Dest: TStream; out ChangedObjectCount: Integer;
  out AppendedByteCount: Int64);
procedure ApplyDefaultOpenAction(Source, Dest: TStream;
  PdfVersion: Integer = 0);
procedure PageLabelledPdfStream(Source, Dest: TStream;
  const Ranges: TPdfPageLabelRanges; ReplaceExisting: Boolean;
  out Report: TPdfPageLabelReport);
procedure InspectOptionalContentPdfStream(Source: TStream;
  Usage: TPdfOptionalContentUsage; ConfigurationIndex: Integer;
  out Inventory: TPdfOptionalContentInventory);
procedure ConfigureOptionalContentPdfStream(Source, Dest: TStream;
  const Changes: TPdfOptionalContentStateChanges;
  const Options: TPdfOptionalContentConfigureOptions;
  out Report: TPdfOptionalContentConfigureReport);
procedure SanitiseActiveContentPdfStream(Source, Dest: TStream;
  const Options: TPdfSanitiseOptions;
  out Report: TPdfSanitiseReport);
procedure SanitiseActiveContentPdfStream(Source, Dest,
  PruneWorkspace: TStream; const Options: TPdfSanitiseOptions;
  out Report: TPdfSanitiseReport);
procedure ExportPdfObjectGraph(Source, Dest: TStream;
  const Options: TPdfObjectGraphInspectOptions;
  out Report: TPdfObjectGraphReport);
procedure PatchPdfObjectGraph(Source, Dest: TStream;
  const Operations: TPdfObjectPatchOperations;
  out Report: TPdfObjectGraphReport;
  AllowSignedDocument: Boolean = False);
procedure PostProcessSavedPdf(Source, Dest: TStream;
  PdfVersion: Integer = 0);
procedure PostProcessSavedPdf(Source, Dest, NormalizedWorkspace,
  RepairedWorkspace, ValidationWorkspace: TStream;
  PdfVersion: Integer = 0);
procedure RepairSubsetToUnicodeCMaps(Source, Dest: TStream);
function ReadPdfVersionInfo(Source: TStream; out Info: TPdfVersionInfo;
  out ErrorText: string): Boolean;
function ReadPdfSparseRevisionInfo(Source: TStream;
  out Info: TPdfSparseRevisionInfo): Boolean;
function ComposePdfSparseUpdateId(Source: TStream;
  const Info: TPdfSparseRevisionInfo;
  const DocumentId, InstanceId: TBytes): AnsiString;
function ReadPdfSparseCatalogSubDict(Source: TStream;
  const Name: AnsiString; out SubDict: AnsiString): Boolean;
function ReadPdfSparsePageDictionaries(Source: TStream;
  out Pages: TPdfSparsePageDictionaries): Boolean;

函式與程序

可呼叫項目說明
TPdfTreeEditor.TryLoad透過稀疏精確世代查詢載入並驗證一個間接 NameTree 或 NumberTree,傳回結構證據,遇到格式錯誤的輸入不引發例外
TPdfTreeEditor.Load載入一個樹,當結構不適合編輯時引發帶驗證錯誤的例外
TPdfTreeEditor.UpsertName and UpsertNumber插入或取代一個排序項目,並保留其完整原始 PDF 值,包括間接參照與複合物件
TPdfTreeEditor.RemoveName, RemoveNumber, and Clear移除選定項目或清空樹,然後進行確定性的重新平衡
TPdfTreeEditor.Validate檢查鍵排序、重複鍵、原始值、項目限制與目前編輯器的不變條件
TPdfTreeEditor.BuildBalancedObjects以精確的 /Limits 建置有界的分葉與內部節點,保留根識別,並盡可能重用相容的已載入間接節點參照
TPdfTreeEditor.SaveIncremental將平衡後的物件附加為經驗證的增量修訂,並在回報成功前獨立重新載入結果
TPdfOutlineEditor.TryLoad and Load透過稀疏精確世代查詢讀取大綱階層,驗證父項與同層連結,偵測循環,並將不支援的目的地與動作保留為不透明字典項目
TPdfOutlineEditor.Add, Delete, and Move以穩定的項目識別碼編輯完整大綱子樹,同時維持深度優先的同層順序
TPdfOutlineEditor.SetTitle, SetStyle, SetExpanded, SetColor, and ClearColor更新可見的大綱呈現,而不捨棄無法識別的項目字典項目
TPdfOutlineEditor.Retarget指派一個以 1 為基底的明確頁面目的地,作為直接 /Dest 資料或帶已驗證目的地後綴的 GoTo 動作
TPdfOutlineEditor.ApplyPageMap使用頁面計畫驗證產生的以 1 為基底目的地對應,更新存留的明確目的地,並移除懸空子樹或加以回報
TPdfOutlineEditor.SaveIncremental重建根、父項、同層、子項、計數、樣式、色彩與目的地項目,附加增量修訂,並在成功前獨立重新載入語意結果
TPdfCrossDocumentGraftMap.Create將可重用的來源到目的地間接物件對應繫結到單一呼叫端提供的來源識別
TPdfCrossDocumentGraftMap.Add and TryResolve儲存並解析精確的物件編號與世代配對,接受完全相同的重複項,拒絕衝突的目的地
GraftPdfAcroForm將欄位階層、視窗元件、外觀、計算順序、預設資源、動作與值匯入到對應的目的地頁面,附加稀疏增量修訂,並在成功前獨立重新載入結果
CompressPdfStream對符合條件的未壓縮串流進行 Flate 壓縮,並重建序列化的 PDF 結構
LinearizePdfStream將作用中物件圖重新排序與重新編號為線性化 PDF 版面,附帶首頁與共用物件提示資料
PackPdfObjectStreams將符合條件的非串流物件打包成有界的 ObjStm 群組並寫出交叉參照串流;兩個分組限制都必須為正數
NormalizePdfDocumentContent以 TPdfContentNormalizeOptions 正規化每個頁面內容序列,並傳回文件層級的 TPdfContentNormalizeReport
PruneUnreachablePdfStream只重寫可從 catalog 到達的物件為單一傳統修訂,同時保留存留的物件編號與世代
PruneUnusedPdfResources掃描頁面、繼承、Form XObject、圖樣、外觀與巢狀資源範圍中已解碼的內容運算子,只移除未使用的資源名稱,附加稀疏修訂,並修剪因此不可到達的物件
DeduplicateResourcesPdfStream修剪不可到達的物件,並合併位元組相同的字型、影像與表單 XObject 子圖
RecompressFlatePdfStream當兩個要求的節省門檻都滿足時,解碼並重新壓縮可到達的 FlateDecode 串流
ExternaliseInlineImagesPdfStream將內嵌影像區塊移入影像 XObject,更新頁面資源,並重寫受影響的內容串流
ReproduciblePdfStream透過修剪不可到達物件、移除 Info 時間戳記並省略來源 /ID,產生確定性的單一修訂輸出
AppendPdfDirtyRevision比較基準與目前語意快照,將變更或新增的間接物件附加到前一個輸出,並回報附加數量
AppendEncryptedPdfDirtyRevision在繼承的加密內容下附加變更或新增的間接物件,並驗證或更新修訂驗證
ApplyDefaultOpenAction在不存在且所選 PDF 版本允許時,注入首頁 Fit-Height 開啟動作,使用有界串流視窗與稀疏延遲查詢,支援傳統、xref-stream、混合與物件串流修訂
PageLabelledPdfStream從以 0 為基底的範圍寫出 catalog /PageLabels 數字樹,可選擇取代現有樹,在一般 xref 路徑上使用有界串流視窗與稀疏 catalog 查詢
InspectOptionalContentPdfStream將選用內容群組、組態、成員關係、使用方式中繼資料與有效可見性讀入清單
ConfigureOptionalContentPdfStream將要求的群組可見性套用到選定的組態,並寫出必要的選用內容更新
SanitiseActiveContentPdfStream透過稀疏查詢與有界範圍複製移除選定的 catalog 與 trailer 主動式內容項目,接著可修剪因此不可到達的物件;工作區多載版本可接受呼叫端自有、有界或磁碟支援的儲存體作為修剪輸入
ExportPdfObjectGraph將有界的間接物件資料序列化為 pdf-object-graph-v1 JSON,可附帶編碼串流的 SHA-256 摘要
PatchPdfObjectGraph依物件識別設定或移除頂層字典項目,並附加經驗證的增量修訂
PostProcessSavedPdf執行預設開啟動作處理、版本專屬正規化與原生增量 xref-stream 修復;具有三個不同可搜尋工作區的多載版本,讓呼叫端能套用自己的有界或磁碟支援儲存政策
RepairSubsetToUnicodeCMaps改寫子集字型中陣列元素與 bfchar 項目互相矛盾的 ToUnicode CMap,採用等長的原地元素編輯(以 bfchar 值為準,僅高位元不同的兩個值取較小的碼點,其他衝突保留第一個對應);沒有 /ToUnicode 的文件,以及採用 xref-stream、hybrid 或 object-stream 版面配置的文件會原樣通過,而每次完整的非增量 TPdf 儲存都會自動套用相同的修復
ReadPdfVersionInfo讀取檔頭、catalog 覆寫、有效核心版本與 Adobe 開發者擴充資訊
ReadPdfSparseRevisionInfo透過稀疏物件索引讀取有界的最新修訂資訊、catalog 位元組、物件世代、xref 樣式、加密狀態、文件識別碼與 Tagged 結構證據
ComposePdfSparseUpdateId以保留呼叫端或來源識別碼、並透過有界串流摘要推導缺失值的方式,格式化增量 trailer /ID
ReadPdfSparseCatalogSubDict透過稀疏物件索引讀取直接或間接的 catalog 子字典,例如 MarkInfo 或 ViewerPreferences
ReadPdfSparsePageDictionaries透過稀疏的傳統、xref-stream、混合與物件串流查詢走訪作用中頁面樹,並依頁面順序傳回頁面字典
TPdfSparseDictionaryReader.Create在呼叫端擁有的來源串流上建置可重用的稀疏索引,並透過 Valid 回報初始化是否成功;使用讀取器期間來源必須保持存活
TPdfSparseDictionaryReader.Destroy釋放保留的索引緩衝區,而不釋放呼叫端擁有的來源串流
TPdfSparseDictionaryReader.ReadDictionary透過保留的索引解析一個精確的物件編號與世代,並傳回有界的作用中字典位元組
TPdfSparseDictionaryReader.ReadLatestDictionary為物件編號解析作用中的 xref 項目,傳回其世代,並透過保留的索引讀取其字典
TPdfSparseDictionaryReader.ReadDecodedStream讀取並解碼一個直接未過濾或單一 FlateDecode 串流,同時強制執行 MaximumDecodedBytes
TPdfOptionalContentConfigureOptions.Default選擇組態 0 與 View 使用方式,移除自動狀態規則,並強制單選群組
TPdfSanitiseOptions.Default啟用開啟動作、catalog 動作、名稱樹、關聯檔案與不可到達物件的移除,同時保留 AcroForm 與中繼資料
TPdfObjectGraphInspectOptions.Default傳回限制:100000 個物件、深度 32、輸出 64 MiB、字串 1 MiB,並啟用串流摘要

類型

類型說明
TPdfTreeKind以 ptkName 選擇位元組排序的 NameTree,或以 ptkNumber 選擇帶號 64 位元 NumberTree
TPdfTreeObjectReference以 ObjectNumber 與 Generation 識別一個間接樹節點
TPdfTreeEntry儲存 NameKey 或 NumberKey,並將一個正規化的完整 PDF 物件存於 RawValue;TPdfTreeEntries 是其動態陣列
TPdfTreeEditOptions限制 MaxEntries、MaxNodes、MaxDepth、MaxLeafEntries 與 MaxKidsPerNode;Default 提供保守的正式環境限制
TPdfTreeValidationIssue單一問題,攜帶物件證據與診斷 Message;TPdfTreeValidationIssues 是其動態陣列
TPdfTreeValidationIssueKind問題值 ptviInvalidRoot、ptviUnreadableNode、ptviCycle、ptviDepthLimit、ptviNodeLimit、ptviEntryLimit、ptviInvalidNodeShape、ptviInvalidKey、ptviInvalidValue、ptviInvalidLimits、ptviDuplicateKey、ptviUnsortedKey 與 ptviDeadlineExceeded
TPdfTreeValidationReport回報 NodeCount、EntryCount、MaximumDepth、Issues、物件證據、成功狀態與錯誤文字
TPdfTreeSerializedObject包含一個平衡節點參照、完整間接物件資料,以及該參照是否被重用
TPdfTreeEditor可變更的排序樹模型,保留不透明 PDF 值,並輸出平衡的間接階層
TPdfOutlineStyleFlag呈現值 posItalic 與 posBold;TPdfOutlineStyle 是它們的集合
TPdfOutlineObjectReference以物件編號與世代識別保留的大綱物件
TPdfOutlineItem儲存穩定識別、父項識別、標題、明確目的地、動作形式、IsOpen、樣式、HasColor、ColorRed、ColorGreen、ColorBlue 與保留物件參照;TPdfOutlineItems 是其動態陣列
TPdfOutlineEditOptions限制 MaxItems 與階層深度,由 Default 提供保守預設值
TPdfOutlineValidationIssueKind問題值 poviNone、poviInvalidCatalog、poviUnreadableItem、poviCycle、poviDepthLimit、poviItemLimit、poviInvalidParent、poviInvalidSibling、poviMissingTitle、poviInvalidDestination、poviInvalidPageMap、poviEncryptedInput、poviWriteFailure 與 poviVerificationFailure
TPdfOutlineValidationReport回報 IssueKind、物件證據、ItemCount、MaximumDepth、RemappedDestinationCount、RemovedDanglingItemCount、成功狀態與錯誤文字
TPdfOutlineEditor可變更的深度優先大綱模型,具備經驗證的頁面計畫重新對應與增量保存
TPdfGraftObjectReference以精確的物件編號與世代識別一個來源或目的地間接物件
TPdfCrossDocumentGraftMap由 TPdfGraftMapEntries 支援、繫結來源識別的可重用物件對應,保留循環與共用參照,並在移植失敗時復原新增的項目
TPdfGraftPageMapping將以 1 為基底的 SourcePageNumber 對應到以 1 為基底的 DestinationPageNumber,用於視窗元件 /P 與頁面 /Annots 更新
TPdfAcroFormCollisionPolicy當來源根欄位標題與目的地根欄位標題衝突時,選擇 pagcpReject 或 pagcpRename
TPdfAcroFormGraftOptions控制 CollisionPolicy、RenamePrefix、物件與遞迴額度,以及 AllowSignedDestination
TPdfAcroFormGraftReport回報 SourceFieldCount、GraftedFieldCount、ReusedObjectCount、DestinationFieldCount、MappedPageCount、GraftedObjectCount、RenamedFieldCount、輸出大小、成功狀態與錯誤文字
TPdfVersionInfo版本報告,含 HeaderVersion、CatalogVersion、CoreVersion、AdobeBaseVersion、AdobeExtensionLevel、HasCatalogVersion、HasDeveloperExtensions 與 HasAdobeExtension
TPdfSparseRevisionInfo最新修訂快照,含 RootObjectNumber、RootGeneration、InfoObjectNumber、InfoGeneration、SizeValue、MaximumObjectNumber、PreviousXrefOffset、UsesXrefStream、HasEncrypt、HasDocumentId、HasTaggedStructure、FirstDocumentId、CatalogDictionary 與 InfoDictionary
TPdfSparseUpdateObject單一修訂項目,含 ObjectNumber、Generation 與攜帶 N G obj ... endobj 位元組的完整 Data 本體
TPdfSparseUpdateObjectsTPdfSparseUpdateObject 項目的動態陣列,由 AppendPdfSparseUpdate 附加
TPdfSparsePageDictionary單一作用中頁面物件,含 ObjectNumber、Generation 與有界的 Dictionary 位元組
TPdfSparsePageDictionaries依頁面樹順序排列的作用中頁面字典動態陣列
TPdfSparseDictionaryReader可重用的稀疏索引擁有者,涵蓋傳統、xref-stream、混合與物件串流索引,可重複進行精確世代字典查詢,而無需來源大小的配置
TPdfPruneReport可達性結果,含 SourceByteCount、OutputByteCount、KeptObjectCount、PrunedObjectCount、Succeeded 與 ErrorMessage
TPdfResourcePruneReport資源修剪結果,含 ScannedScopeCount、UpdatedScopeCount、RemovedNameCount、RemovedObjectCount、串流計數、位元組總計、成功狀態與錯誤文字
TPdfDedupReport去重複結果,含 SourceByteCount、OutputByteCount、KeptObjectCount、PrunedObjectCount、MergedFontCount、MergedImageCount、MergedFormXObjectCount、Succeeded 與 ErrorMessage
TPdfFlateRecompressOptions取代門檻 MinSavingBytes 與 MinSavingRatio
TPdfFlateRecompressReport重新壓縮結果,含 SourceByteCount、OutputByteCount、RecompressedCount、SkippedCount、FailedCount、OriginalStreamBytes、RecompressedStreamBytes、Succeeded 與 ErrorMessage
TPdfInlineImageExternaliseOptions包含 SkipUnsafePages,保留無法解析內嵌影像邊界的頁面
TPdfInlineImageExternaliseReport外置結果,含 SourceByteCount、OutputByteCount、ExternalisedCount、SkippedPageCount、FailedCount、CreatedXObjectCount、Succeeded 與 ErrorMessage
TPdfReproducibleReport確定性重寫結果,含 SourceByteCount、OutputByteCount、KeptObjectCount、PrunedObjectCount、StrippedTimestampCount、Succeeded 與 ErrorMessage
TPdfPageLabelStyle編號樣式 plsNone、plsDecimal、plsUppercaseRoman、plsLowercaseRoman、plsUppercaseLetters 與 plsLowercaseLetters
TPdfPageLabelRange單一標籤範圍,含以 0 為基底的 StartPageIndex、Style、Prefix 與 StartNumber
TPdfPageLabelRangesTPdfPageLabelRange 值的動態陣列
TPdfPageLabelReport標籤重寫結果,含 SourceByteCount、OutputByteCount、AppliedRangeCount、ReplacedExistingLabels、Succeeded 與 ErrorMessage
TPdfOptionalContentUsage可見性情境 ocuView、ocuPrint、ocuExport 與 ocuDesign
TPdfOptionalContentState依使用方式的狀態 ocsUnspecified、ocsOn 與 ocsOff
TPdfOptionalContentBaseState組態基礎狀態 ocbsOn、ocbsOff 與 ocbsUnchanged
TPdfOptionalContentMembershipPolicy成員關係政策 ocmpAnyOn、ocmpAllOn、ocmpAnyOff、ocmpAllOff 與 ocmpUnknown
TPdfOptionalContentIntegerArray動態整數陣列,用於選用內容物件編號集合
TPdfOptionalContentStringArray動態 AnsiString 陣列,用於 PDF 名稱集合
TPdfOptionalContentWideStringArray動態 WideString 陣列,用於已解碼的選用內容文字
TPdfOptionalContentRadioGroup由 GroupObjectNumbers 表示的單一互斥群組
TPdfOptionalContentRadioGroupsTPdfOptionalContentRadioGroup 值的動態陣列
TPdfOptionalContentGroupOCG 記錄,含 ObjectNumber、Generation、Name、Intents、ViewState、PrintState、ExportState、PageElementSubtype、Language、LanguagePreferred、UserType、UserNames、HasZoomRange、MinimumZoom、MaximumZoom、EffectiveVisible、Locked 與 RadioGroupIndex
TPdfOptionalContentGroupsTPdfOptionalContentGroup 值的動態陣列
TPdfOptionalContentConfiguration組態記錄,含 ObjectNumber、Generation、Name、Creator、BaseState、Intents、OnGroupObjectNumbers、OffGroupObjectNumbers、LockedGroupObjectNumbers、OrderGroupObjectNumbers、RadioGroups 與 HasAutomaticState
TPdfOptionalContentConfigurationsTPdfOptionalContentConfiguration 值的動態陣列
TPdfOptionalContentMembershipOCMD 記錄,含 ObjectNumber、Generation、GroupObjectNumbers、Policy、VisibilityExpression 與 EffectiveVisible
TPdfOptionalContentMembershipsTPdfOptionalContentMembership 值的動態陣列
TPdfOptionalContentInventory檢查結果,含 Usage、SelectedConfigurationIndex、Groups、Configurations、Memberships、Succeeded 與 ErrorMessage
TPdfOptionalContentStateChange單一 GroupObjectNumber 所要求的 Visible 狀態
TPdfOptionalContentStateChangesTPdfOptionalContentStateChange 值的動態陣列
TPdfOptionalContentConfigureOptions選定的組態與使用方式,加上 DisableAutomaticState 與 EnforceRadioGroups 控制
TPdfOptionalContentConfigureReport組態結果,含 SourceByteCount、OutputByteCount、GroupCount、ChangedGroupCount、UpdatedUsageStateCount、SelectedConfigurationIndex、RemovedAutomaticState、Succeeded 與 ErrorMessage
TPdfSanitiseOptions獨立的 StripOpenAction、StripCatalogActions、StripNames、StripAssociatedFiles、StripAcroForm、StripMetadata 與 RemoveUnreachable 控制
TPdfSanitiseReport清理結果,含 SourceByteCount、OutputByteCount、StrippedEntryCount、PrunedObjectCount、巢狀 PruneReport、Succeeded 與 ErrorMessage
TPdfObjectGraphInspectOptions以 MaxObjects、MaxDepth、MaxOutputBytes、MaxStringBytes 與 IncludeStreamDigests 限制 JSON 匯出
TPdfObjectGraphReport共用的匯出與修補結果,含 SourceByteCount、OutputByteCount、ObjectCount、ExportedObjectCount、PatchedObjectCount、AppliedOperationCount、Truncated、Succeeded 與 ErrorMessage
TPdfObjectPatchOperationKind修補動作 popSet 與 popRemove
TPdfObjectPatchValueKind值種類 povNull、povBoolean、povInteger、povReal、povName、povTextString 與 povReference
TPdfObjectPatchValue帶標籤的值,含 Kind、BooleanValue、IntegerValue、RealValue、TextValue、ReferenceObjectNumber 與 ReferenceGeneration
TPdfObjectPatchOperation單一操作,含 Kind、ObjectNumber、Generation、Key 與 Value
TPdfObjectPatchOperationsTPdfObjectPatchOperation 值的動態陣列

安全性與限制

TPdfOutlineEditor.SetUri 以 UTF-8 URI 動作取代目的地,並安全編碼字面值分隔符號;儲存驗證會忽略葉節點的展開狀態,因為 PDF 不會為它們儲存分支 Count

GraftPdfAcroForm 的選項多載支援 pagcpReject、pagcpRename、pagcpNamespace,以及相容的終端文字/選項欄位合併,並依選取頁面裁去 Widget、隔離資源、外觀及計算順序;策略與交易式文件整合請參閱 FPdfFormMerge

AcroForm 衝突報告

TPdfAcroFormGraftOptions.NamespacePrefix 指定命名空間策略插入的父節點名稱;TPdfAcroFormCollisionPolicy.pagcpMergeCompatible 合併受支援且相容的終端文字或選項欄位

TPdfAcroFormGraftReport.FilteredFieldCount 與 TPdfAcroFormGraftReport.FilteredWidgetCount 計算因頁面篩選而移除的來源項目;TPdfAcroFormGraftReport.ResourceRenameCount 計算隔離的預設資源名稱,TPdfAcroFormGraftReport.MergedFieldCount 則計算合併至既有擁有者的相容欄位

CapturePdfNavigation 與 WritePdfNavigation 透過明確的擁有者頁面對應,擷取並重新對應具名目的地與頁面連結註解;原始鍵值語意、目的地參數、上限與交易式整合請參閱 FPdfMerge

導覽擷取記錄

TPdfNavigationNamedDestination= record
    // Keep the original PDF string bytes, including a UTF-16 BOM when present
    NameKey: AnsiString;
    // Absolute one-based page number; zero denotes an unresolved target
    PageNumber: Integer;
    // Exact destination mode and parameters, including null values
    DestinationSuffix: AnsiString;
  end;
  TPdfNavigationNamedDestinations= array of TPdfNavigationNamedDestination;
  TPdfNavigationPageLink= record
    // Owner page is one-based; annotation and link-only ordinals are zero-based
    PageNumber, AnnotationIndex, LinkIndex: Integer;
    HasDestination, HasGotoAction: Boolean;
    DestinationPageNumber, ActionPageNumber: Integer;
    DestinationSuffix, ActionSuffix: AnsiString;
  end;
  TPdfNavigationPageLinks= array of TPdfNavigationPageLink;

讀取使用中的物件值

ReadPdfActiveObjects 傳回最新使用中的物件值、確切的世代編號及使用中的目錄修訂,解析傳統 xref 表格、xref 串流、增量修訂與壓縮物件串流成員

Body 不含間接物件標頭與 endobj 標記;一般串流保留字典與編碼後的酬載,壓縮成員則具體化為一般值,傳回集合不含 xref/物件串流的基礎結構物件

會還原來源位置;失敗時傳回空的物件集合與診斷。加密輸入會遭拒絕,簽章則可以在不改動位元組的情況下檢查

預設允許 256 MiB 來源位元組、每個具體化本文 64 MiB、累計本文 256 MiB、每個解碼物件串流 64 MiB、累計解碼物件串流快取 256 MiB,以及 1,000,000 個物件編號槽位

每次複製本文之前都會檢查上限,臨時基礎結構本文與傳回值都納入計算;另外命名的解碼快取上限,會在超出呼叫端預算之前停止物件串流解碼

這些是邏輯緩衝區上限,並非整個程序的記憶體上限:來源副本、直接物件暫存串流、掃描緩衝區、解碼工作空間與物件中繼資料仍會消耗額外但有上限的配置,掃描緩衝區也可能複製保留的本文

type
  TPdfActiveObject = record
    ObjectNumber, Generation: Integer;
    Body: TBytes;
  end;
  TPdfActiveObjects = array of TPdfActiveObject;
  TPdfActiveObjectReadOptions = record
    MaxSourceBytes, MaxObjectBytes, MaxTotalObjectBytes: Int64;
    MaxDecodedObjectStreamBytes, MaxTotalDecodedObjectStreamBytes: Int64;
    MaxObjects: Integer;
    class function Default: TPdfActiveObjectReadOptions; static;
  end;

function ReadPdfActiveObjects(Source: TStream;
  const Options: TPdfActiveObjectReadOptions; out Objects: TPdfActiveObjects;
  out Revision: TPdfSparseRevisionInfo; out ErrorText: string): Boolean;

另請參閱

FPdfContentNormalize, TPdf.SaveAs, TPdf.SaveAsNormalizedContent, TPdf.InspectOptionalContent, TPdf.ObjectGraph, ReadPdfVersionInfo