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仅把从目录可达的对象重写为一个经典修订,同时保留存留对象的编号与代次
PruneUnusedPdfResources扫描页面、继承、Form XObject、图案、外观和嵌套资源作用域中的已解码内容运算符,仅移除未使用的资源名称,追加稀疏修订,并修剪因此不可达的对象
DeduplicateResourcesPdfStream修剪不可达对象,并合并字节级相同的字体、图像和窗体 XObject 子图
RecompressFlatePdfStream当同时满足两个请求的节省阈值时,解码并重新压缩可达的 FlateDecode 流
ExternaliseInlineImagesPdfStream将内联图像块移动到图像 XObject 中,更新页面资源,并重写受影响的内容流
ReproduciblePdfStream通过修剪不可达对象、移除 Info 时间戳和省略源 /ID,产生确定性的单修订输出
AppendPdfDirtyRevision比较基线与当前语义快照,将变更或新增的间接对象追加到上一次输出,并报告追加数量
AppendEncryptedPdfDirtyRevision在继承的加密上下文下追加变更或新增的间接对象,并验证或更新修订身份验证
ApplyDefaultOpenAction当不存在打开动作且所选 PDF 版本允许时,注入首页 Fit-Height 打开动作,使用有界流窗口和稀疏惰性查找,覆盖经典、xref 流、混合和对象流修订
PageLabelledPdfStream从基于 0 的区间写入目录 /PageLabels 编号树,并可选择替换现有树,在常规 xref 路径上使用有界流窗口和稀疏目录查找
InspectOptionalContentPdfStream将可选内容组、配置、成员关系、使用元数据和有效可见性读入清单
ConfigureOptionalContentPdfStream将请求的组可见性应用到所选配置,并写入所需的可选内容更新
SanitiseActiveContentPdfStream通过稀疏查找和有界范围复制剥离选定的目录与 trailer 活动内容条目,随后可修剪因此不可达的对象;工作区重载接受调用方持有的有界或磁盘后备存储作为修剪输入
ExportPdfObjectGraph将有界的间接对象数据序列化为 pdf-object-graph-v1 JSON,可选携带编码流的 SHA-256 摘要
PatchPdfObjectGraph按对象标识设置或移除顶层字典条目,并追加经过验证的增量修订
PostProcessSavedPdf执行默认打开动作处理、版本相关规范化和原生增量 xref 流修复;带三个相互独立可寻址工作区的重载让调用方应用自己的有界或磁盘后备存储策略
RepairSubsetToUnicodeCMaps重写数组元素与 bfchar 条目互相矛盾的子集字体 ToUnicode CMap,采用等长的就地元素编辑(bfchar 取值优先,仅高位不同的编码对取较小的码点,其他冲突保留第一个映射);没有 /ToUnicode 的文档以及 xref 流、混合、对象流布局原样通过,且每次完整的非增量 TPdf 保存都会自动应用同样的修复
ReadPdfVersionInfo读取文件头版本、目录覆盖版本、有效核心版本和 Adobe 开发者扩展信息
ReadPdfSparseRevisionInfo通过稀疏对象索引读取有界的最新修订事实、目录字节、对象代次、xref 风格、加密状态、文档标识符和标记结构证据
ComposePdfSparseUpdateId格式化增量 trailer /ID,保留调用方或源标识符,并通过有界的流式摘要推导缺失值
ReadPdfSparseCatalogSubDict通过稀疏对象索引读取直接或间接的目录子字典,例如 MarkInfo 或 ViewerPreferences
ReadPdfSparsePageDictionaries通过稀疏的经典、xref 流、混合和对象流查找遍历活动页面树,并按页面顺序返回页面字典
TPdfSparseDictionaryReader.Create在调用方持有的源流上构建可复用的稀疏索引,并通过 Valid 报告初始化是否成功;使用读取器期间源流必须保持存活
TPdfSparseDictionaryReader.Destroy释放保留的索引缓冲区,而不释放调用方持有的源流
TPdfSparseDictionaryReader.ReadDictionary通过保留的索引解析一个精确的对象编号与代次,并返回有界的活动字典字节
TPdfSparseDictionaryReader.ReadLatestDictionary解析对象编号的活动 xref 条目,返回其代次,并通过保留的索引读取其字典
TPdfSparseDictionaryReader.ReadDecodedStream读取并解码一个直接的未过滤流或单一 FlateDecode 流,同时强制执行 MaximumDecodedBytes
TPdfOptionalContentConfigureOptions.Default选择配置 0 和 View 用途,移除自动状态规则,并强制单选组
TPdfSanitiseOptions.Default启用打开动作、目录动作、名称树、关联文件和不可达对象移除,同时保留 AcroForm 和元数据
TPdfObjectGraphInspectOptions.Default返回以下限制:100000 个对象、深度 32、64 MiB 输出、1 MiB 字符串,并启用流摘要

类型

类型说明
TPdfTreeKind以 ptkName 选择按字节排序的 NameTree,或以 ptkNumber 选择带符号 64 位的 NumberTree
TPdfTreeObjectReference通过 ObjectNumber 和 Generation 标识一个间接树节点
TPdfTreeEntry存储 NameKey 或 NumberKey,并在 RawValue 中保存一个规范化的完整 PDF 对象;TPdfTreeEntries 是其动态数组
TPdfTreeEditOptions约束 MaxEntries、MaxNodes、MaxDepth、MaxLeafEntries 和 MaxKidsPerNode;Default 提供保守的生产限制
TPdfTreeValidationIssue携带对象证据和诊断 Message 的单个问题;TPdfTreeValidationIssues 是其动态数组
TPdfTreeValidationIssueKind问题值 ptviInvalidRoot, ptviUnreadableNode, ptviCycle, ptviDepthLimit, ptviNodeLimit, ptviEntryLimit, ptviInvalidNodeShape, ptviInvalidKey, ptviInvalidValue, ptviInvalidLimits, ptviDuplicateKey, ptviUnsortedKey, and 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, and 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, and InfoDictionary
TPdfSparseUpdateObject单个修订条目,含 ObjectNumber、Generation 和携带 N G obj ... endobj 字节的完整 Data 对象体
TPdfSparseUpdateObjects由 AppendPdfSparseUpdate 追加的 TPdfSparseUpdateObject 条目动态数组
TPdfSparsePageDictionary单个活动页面对象,含 ObjectNumber、Generation 和有界的 Dictionary 字节
TPdfSparsePageDictionaries按页面树顺序排列的活动页面字典动态数组
TPdfSparseDictionaryReader可复用的稀疏经典、xref 流、混合和对象流索引持有者,支持重复的精确代次字典查找而无需按源大小分配
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用于 PDF 名称集合的动态 AnsiString 数组
TPdfOptionalContentWideStringArray用于已解码可选内容文本的动态 WideString 数组
TPdfOptionalContentRadioGroup由 GroupObjectNumbers 表示的单个互斥组
TPdfOptionalContentRadioGroupsTPdfOptionalContentRadioGroup 值的动态数组
TPdfOptionalContentGroupOCG 记录,含 ObjectNumber, Generation, Name, Intents, ViewState, PrintState, ExportState, PageElementSubtype, Language, LanguagePreferred, UserType, UserNames, HasZoomRange, MinimumZoom, MaximumZoom, EffectiveVisible, Locked, and RadioGroupIndex
TPdfOptionalContentGroupsTPdfOptionalContentGroup 值的动态数组
TPdfOptionalContentConfiguration配置记录,含 ObjectNumber, Generation, Name, Creator, BaseState, Intents, OnGroupObjectNumbers, OffGroupObjectNumbers, LockedGroupObjectNumbers, OrderGroupObjectNumbers, RadioGroups, and 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 返回最新有效对象值、其精确世代号及当前有效 catalog 修订,解析传统 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