PDFium Delphi Component Docs

FPdfProduction 单元

面向图形、文档内容、交互包和嵌入式媒体的有界生产工作流

异常与枚举

声明取值或用途
EPdfProduction在生产输入无效、安全预算耗尽、操作不受支持或后端输出被拒绝时引发的异常
TPdfColourSpacepcsDeviceGray, pcsDeviceRGB, pcsDeviceCMYK, pcsICCBased, pcsSeparation, pcsDeviceN, pcsLab
TPdfSvgPathCommandKindspcMoveTo, spcLineTo, spcCubicTo, spcQuadraticTo, spcClosePath
TPdfReplacementModeprmNativeTextObject, prmRedactAndRelayout
TPdfBarcodeKindpbkCode128, pbkQr, pbkDataMatrix, pbkPdf417
TPdfPortfolioFieldTypeppftText, ppftNumber, ppftDate, ppftFileName, ppftDescription, ppftSize, ppftModDate, ppftCreationDate

颜色转换声明

可选的 LittleCMS 提供器实现缓冲区转换接口,FPdfDocumentColour 将其应用于原始文档操作符和图像分量,并明确报告是否转换完整

声明公开字段或成员
pcsLabICC v4 D50 PCS Lab 源,带三个本机字节序的 16-bit 分量,且不含源配置文件字节;L 使用 L*655.35,a/b 使用 (value+128)*257
TPdfColourBufferSpace: TPdfColourSpace, Components: Integer, BitsPerComponent: Integer, Samples: TBytes, IccProfile: TBytes
TPdfOutputIntentIdentifier: string, RegistryName: string, Info: string, Components: Integer, IccProfile: TBytes
TPdfColourConversionOptionsMaxInputBytes: Integer, MaxOutputBytes: Integer, PreserveOnFailure: Boolean, class function Default: TPdfColourConversionOptions
TPdfColourConversionReportConverted: Boolean, PreservedOriginal: Boolean, InputBytes: Integer, OutputBytes: Integer, ErrorMessage: string

字体与 SVG 声明

TPdfTrueTypeSubsetBackend 提供带复合闭包、保留 ID 的轮廓子集化;SubsetPdfDocumentFonts 把它应用到经过验证的嵌入文档资源上

声明公开字段或成员
TPdfGlyphInfoGlyphID: Cardinal, UnicodeValue: Cardinal, Width: Integer
TPdfGlyphInfosTPdfGlyphInfo 的动态数组
TPdfFontSubsetOptionsMaxFontBytes: Integer, MaxGlyphs: Integer, MinimumSavingPercent: Integer, RestrictToContentStreamUsage: Boolean, class function Default: TPdfFontSubsetOptions
TPdfFontSubsetReportApplied: Boolean, PreservedOriginal: Boolean, GlyphCount: Integer, OriginalBytes: Integer, SubsetBytes: Integer, ErrorMessage: string
TPdfSvgPathCommandKind: TPdfSvgPathCommandKind, Values: array[0..5] of Double
TPdfSvgPathCommandsTPdfSvgPathCommand 的动态数组

IPdfFontSubsetClosureBackend 可选扩展后端,增加 function SubsetWithClosure(const FontProgram: TBytes; const Glyphs: TPdfGlyphInfos; out SubsetProgram: TBytes; out GlyphClosure: TPdfGlyphInfos; out ErrorMessage: string): Boolean,返回实际排序去重后的依赖

SubsetExistingPdfFont 使用稳定排序保留重复 glyph ID 的首个元数据,校验扩展闭包预算和请求 glyph 覆盖情况,并在接受更小的程序之前报告实际闭包数量

保留样式替换与 XFA 声明

声明公开字段或成员
TPdfStyledSpanPageIndex: Integer, ObjectIndex: Integer, CharacterStart: Integer, Text: WideString, StyleID: Integer
TPdfStyledSpansTPdfStyledSpan 的动态数组
TPdfRegexMatchStartIndex: Integer, Length: Integer, Replacement: WideString
TPdfRegexMatchesTPdfRegexMatch 的动态数组
TPdfStyledReplacementMode: TPdfReplacementMode, PageIndex: Integer, FirstObjectIndex: Integer, LastObjectIndex: Integer, FirstCharacter: Integer, CharacterCount: Integer, Replacement: WideString, StyleID: Integer, LastPageIndex: Integer
TPdfStyledReplacementsTPdfStyledReplacement 的动态数组
TPdfXfaBindingSomPath: string, Value: string
TPdfXfaBindingsTPdfXfaBinding 的动态数组

条码与 Portfolio 声明

FPdfDocumentAssets 为这些模型提供文档级 Collection 读写和 RichMedia 发现

声明公开字段或成员
TPdfBarcodeRectLeft: Double, Top: Double, Right: Double, Bottom: Double
TPdfBarcodeRectsTPdfBarcodeRect 的动态数组
TPdfBarcodeResultKind: TPdfBarcodeKind, Text: string, Bounds: TPdfBarcodeRect, Confidence: Double
TPdfBarcodeResultsTPdfBarcodeResult 的动态数组
TPdfPortfolioFieldName: string, DisplayName: string, FieldType: TPdfPortfolioFieldType, Order: Integer, Visible: Boolean, Editable: Boolean
TPdfPortfolioFieldsTPdfPortfolioField 的动态数组
TPdfPortfolioValueFieldName: string, Value: string, Prefix: string
TPdfPortfolioValuesTPdfPortfolioValue 的动态数组
TPdfPortfolioItemKey: string, FileName: string, Description: string, AFRelationship: string, FolderID: Integer, Values: TPdfPortfolioValues, EmbeddedData: TBytes, MimeType: string, CreationDate: string, ModificationDate: string, IsExternal: Boolean
TPdfPortfolioItemsTPdfPortfolioItem 的动态数组
TPdfPortfolioSplitDirection(ppsdNone, ppsdHorizontal, ppsdVertical)
TPdfPortfolioFolderID: Integer、ParentID: Integer、Name: string、Description: string、CreationDate: string、ModificationDate: string、Values: TPdfPortfolioValues
TPdfPortfolioFoldersTPdfPortfolioFolder 的动态数组
TPdfPortfolioSortFieldName: string、Ascending: Boolean
TPdfPortfolioSortFieldsTPdfPortfolioSortField 的动态数组
TPdfPortfolioFields: TPdfPortfolioFields, Items: TPdfPortfolioItems, Folders: TPdfPortfolioFolders, SortField: string, SortAscending: Boolean, SortFields: TPdfPortfolioSortFields, InitialDocument: string, View: TPdfPortfolioView, HasSplit: Boolean, SplitDirection: TPdfPortfolioSplitDirection, SplitPosition: Double, HasColors: Boolean, BackgroundColor: Cardinal, CardBackgroundColor: Cardinal, CardBorderColor: Cardinal, PrimaryTextColor: Cardinal, SecondaryTextColor: Cardinal

TPdfPortfolioView 选择 ppvDetails、ppvTiles 或 ppvHidden;Key 独立于 FileName 标识名称树条目,Prefix 保存 Collection 子条目的显示前缀,InitialDocument 选择条目的 Key

RichMedia 声明

声明公开字段
TPdfRichMediaAssetName: string, MimeType: string, Data: TBytes, IsExternal: Boolean, ActivationCondition: string, DefaultView: string
TPdfRichMediaAssetsTPdfRichMediaAsset 的动态数组
TPdfRichMediaExtractedName: string, MimeType: string, Size: Int64, Sha256: string
TPdfRichMediaExtractedArrayTPdfRichMediaExtracted 的动态数组

后端接口

接口方法用途
IPdfColourTransformfunction Transform(const Source: TPdfColourBuffer; TargetSpace: TPdfColourSpace; const TargetProfile: TBytes; out Target: TPdfColourBuffer): Boolean将已验证的源缓冲区转换到请求的色彩空间和配置文件
IPdfColourFloatTransformfunction TransformFloat(const Source: TPdfColourBuffer; TargetSpace: TPdfColourSpace; const TargetProfile: TBytes; TargetBitsPerComponent: Integer; out Target: TPdfColourBuffer): Boolean自 v3.312.0 起提供的可选接口:每像素三个按原生字节序排列的 IEEE 754 Single PCS Lab 值(物理 Lab 单位),无源配置文件,目标精度可选 8/16 位;基础接口与 ConvertPdfColourBuffer 仍接受整数输入
IPdfFontSubsetBackendfunction Subset(const FontProgram: TBytes; const Glyphs: TPdfGlyphInfos; out SubsetProgram: TBytes): Boolean构建包含请求字形闭包的字体程序
IPdfRegexEnginefunction FindMatches(const Text, Pattern, Replacement: WideString; MaxMatches: Integer): TPdfRegexMatches返回有界的正则表达式匹配和替换文本
IPdfBarcodeProviderfunction Generate(Kind: TPdfBarcodeKind; const Text: string; ModuleSize: Double; out Rects: TPdfBarcodeRects): Boolean为受支持的码制生成条码模块矩形
function Recognise(const Pixels: TBytes; Width, Height, Stride: Integer; MaxResults: Integer): TPdfBarcodeResults从调用方拥有的像素缓冲区识别有界的条码结果

默认选项工厂方法

成员用途
class function TPdfColourConversionOptions.Default: TPdfColourConversionOptions返回启用源保留的有界颜色转换默认值
class function TPdfFontSubsetOptions.Default: TPdfFontSubsetOptions返回带最小节省阈值的有界字体和字形限制;自 v3.207.0 起,实际节省百分比在比较前向下取整,因此非空子集不可能满足 100% 的阈值

全局函数与过程

函数签名说明
function ConvertPdfColourBuffer(const Source: TPdfColourBuffer; TargetSpace: TPdfColourSpace; const TargetProfile: TBytes; Transform: IPdfColourTransform; const Options: TPdfColourConversionOptions; out Target: TPdfColourBuffer; out OutputIntent: TPdfOutputIntent; out Report: TPdfColourConversionReport): Boolean让颜色缓冲区经过调用方转换,构建匹配的 OutputIntent 数据,并在失败时保留源
function SubsetExistingPdfFont(const FontProgram: TBytes; const UsedGlyphs: TPdfGlyphInfos; Backend: IPdfFontSubsetBackend; const Options: TPdfFontSubsetOptions; out ResultProgram: TBytes; out GlyphClosure: TPdfGlyphInfos; out Report: TPdfFontSubsetReport): Boolean规范化请求的 glyph,从可选的 IPdfFontSubsetClosureBackend 获取依赖,并且只在声明的预算内接受更小的程序
function ParsePdfSvgPath(const Data: string; MaxCommands: Integer = 100000): TPdfSvgPathCommands解析有界的移动、直线、三次、二次和闭合命令,并支持相对坐标
function ExportPdfSvgPath(const Commands: TPdfSvgPathCommands): string将路径命令序列化为绝对 SVG 路径语法
procedure TransformPdfSvgPath(var Commands: TPdfSvgPathCommands; A, B, C, D, E, F: Double)对已解析 SVG 路径中的每个坐标应用仿射矩阵
function BuildStyledRegexReplacementPlan(const Spans: TPdfStyledSpans; const Pattern, Replacement: WideString; Engine: IPdfRegexEngine; MaxCharacters: Integer = 16 * 1024 * 1024; MaxMatches: Integer = 100000): TPdfStyledReplacements把正则表达式匹配映射回带样式的页面对象范围,并选择原生或基于涂黑的替换
function MergePdfXfaDatasets(const Packets: TXfaPacketList; const Bindings: TPdfXfaBindings; MaxPacketBytes: Integer = 32 * 1024 * 1024): TXfaPacketList把转义的 SOM 叶子绑定合并进 UTF-8 数据集,支持 SOM 路径里的 Unicode XML 元素名,同时保留每个未改动的 XFA 包
function RewritePdfXfaPacketStreams(Source, Destination: TStream; const Packets: TXfaPacketList; MaxTotalPacketBytes: Int64 = 256 * 1024 * 1024): Boolean把事务性替换的 XFA 包流追加到未加密 PDF
function GeneratePdfBarcode(Kind: TPdfBarcodeKind; const Text: string; ModuleSize: Double; Provider: IPdfBarcodeProvider = nil): TPdfBarcodeRects生成内置的 Code 128-B 矢量,并把二维码制委托给提供方
function RecognisePdfBarcodes(const Pixels: TBytes; Width, Height, Stride: Integer; Provider: IPdfBarcodeProvider; MaxResults: Integer = 256): TPdfBarcodeResults在强制图像几何和结果边界的前提下委托条码识别
procedure ValidatePdfPortfolio(const Portfolio: TPdfPortfolio; MaxItems: Integer = 100000; MaxEmbeddedBytes: Int64 = 1024 * 1024 * 1024)验证字段定义、值、条目数量和嵌入载荷预算
procedure SortPdfPortfolio(var Portfolio: TPdfPortfolio)按顺序应用配置的排序键并稳定处理平局,创建确定性的 Collection 视图;存在 SortFields 时使用它,否则退回旧的单字段对
function ExtractPdfRichMediaAssets(const Assets: TPdfRichMediaAssets; const OutputDirectory: string; MaxAssetBytes: Int64 = 256 * 1024 * 1024; MaxTotalBytes: Int64 = 1024 * 1024 * 1024): TPdfRichMediaExtractedArray写出嵌入资产,不执行内容、不解析外部引用,也不允许目录逃逸

FPdfBarcodeZXing 提供可选的条码生成和识别提供器

安全模型

颜色与字体的输入预算会在分配保留副本之前先检查;源 ICC profile 同样受颜色输入字节上限约束

SVG 解析在完成相对坐标运算后拒绝非有限坐标;TransformPdfSvgPath 先校验一份私有候选结果再替换调用方数组,失败时输入及其别名都保持不变

RichMedia 提取会拒绝路径分隔符、控制字符、Windows 保留设备名以及结尾的句点或空格,并以独占方式创建每个输出文件,从校验到创建之间已有文件不会被截断

提取失败时,清理范围包括当前正在写入的文件以及本次调用之前已创建的文件;提取期间调用方必须始终掌控输出目录

平台编解码器、颜色引擎、字体子集化器、正则表达式引擎、矩阵条码库和识别器都是显式接口,宿主可以选择自己审计过的后端

FPdfStyledEdit 针对已验证的源快照执行这些计划,支持预览、字体复用或显式后备、受限适配,以及事务式保存/重新打开验证