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 保留第一筆 metadata、驗證延伸的閉包預算與要求的 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 起的選用介面:每像素接受三個原生位元組序、實體 Lab 單位的 IEEE 754 Single PCS Lab 值,無來源描述檔,並明確指定 8/16-bit 目標精度;基底介面與 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 起,比較前會先對實際節省百分比做無條件捨去,因此非空的 subset 不可能滿足 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 針對經驗證的來源快照執行這些計畫,支援預覽、字型重用或明確備援、有上限的尺寸調整,以及交易式儲存/重新開啟驗證