PDFium Delphi Component Docs

FPdfProduction unit

Bounded production workflows for graphics, document content, interactive packages, and embedded media

Exception and enumerations

DeclarationValues or purpose
EPdfProductionException raised for invalid production input, exhausted safety budgets, unsupported operations, and rejected backend output
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

Colour conversion declarations

The optional LittleCMS provider implements the buffer transform interface, and FPdfDocumentColour applies it to original document operators and image components with explicit completeness reports

DeclarationPublic fields or members
pcsLabICC v4 D50 PCS Lab source with three native-endian 16-bit components and no source profile bytes; L uses L*655.35 and a/b use (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

Font and SVG declarations

TPdfTrueTypeSubsetBackend provides retained-ID outline subsetting with composite closure; SubsetPdfDocumentFonts applies it to proven embedded document resources

DeclarationPublic fields or members
TPdfGlyphInfoGlyphID: Cardinal, UnicodeValue: Cardinal, Width: Integer
TPdfGlyphInfosDynamic array of TPdfGlyphInfo
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
TPdfSvgPathCommandsDynamic array of TPdfSvgPathCommand

IPdfFontSubsetClosureBackend optionally extends a backend with function SubsetWithClosure(const FontProgram: TBytes; const Glyphs: TPdfGlyphInfos; out SubsetProgram: TBytes; out GlyphClosure: TPdfGlyphInfos; out ErrorMessage: string): Boolean, returning actual sorted unique dependencies

SubsetExistingPdfFont keeps the first metadata for duplicate glyph IDs using stable sorting, validates extended closure budgets and requested-glyph coverage, and reports the actual closure count before accepting a smaller program

Styled replacement and XFA declarations

DeclarationPublic fields or members
TPdfStyledSpanPageIndex: Integer, ObjectIndex: Integer, CharacterStart: Integer, Text: WideString, StyleID: Integer
TPdfStyledSpansDynamic array of TPdfStyledSpan
TPdfRegexMatchStartIndex: Integer, Length: Integer, Replacement: WideString
TPdfRegexMatchesDynamic array of TPdfRegexMatch
TPdfStyledReplacementMode: TPdfReplacementMode, PageIndex: Integer, FirstObjectIndex: Integer, LastObjectIndex: Integer, FirstCharacter: Integer, CharacterCount: Integer, Replacement: WideString, StyleID: Integer, LastPageIndex: Integer
TPdfStyledReplacementsDynamic array of TPdfStyledReplacement
TPdfXfaBindingSomPath: string, Value: string
TPdfXfaBindingsDynamic array of TPdfXfaBinding

Barcode and Portfolio declarations

FPdfDocumentAssets provides document-level Collection read/write and RichMedia discovery for these models

DeclarationPublic fields or members
TPdfBarcodeRectLeft: Double, Top: Double, Right: Double, Bottom: Double
TPdfBarcodeRectsDynamic array of TPdfBarcodeRect
TPdfBarcodeResultKind: TPdfBarcodeKind, Text: string, Bounds: TPdfBarcodeRect, Confidence: Double
TPdfBarcodeResultsDynamic array of TPdfBarcodeResult
TPdfPortfolioFieldName: string, DisplayName: string, FieldType: TPdfPortfolioFieldType, Order: Integer, Visible: Boolean, Editable: Boolean
TPdfPortfolioFieldsDynamic array of TPdfPortfolioField
TPdfPortfolioValueFieldName: string, Value: string, Prefix: string
TPdfPortfolioValuesDynamic array of TPdfPortfolioValue
TPdfPortfolioItemKey: string, FileName: string, Description: string, AFRelationship: string, FolderID: Integer, Values: TPdfPortfolioValues, EmbeddedData: TBytes, MimeType: string, CreationDate: string, ModificationDate: string, IsExternal: Boolean
TPdfPortfolioItemsDynamic array of TPdfPortfolioItem
TPdfPortfolioSplitDirection(ppsdNone, ppsdHorizontal, ppsdVertical)
TPdfPortfolioFolderID: Integer, ParentID: Integer, Name: string, Description: string, CreationDate: string, ModificationDate: string, Values: TPdfPortfolioValues
TPdfPortfolioFoldersDynamic array of TPdfPortfolioFolder
TPdfPortfolioSortFieldName: string, Ascending: Boolean
TPdfPortfolioSortFieldsDynamic array of TPdfPortfolioSortField
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 selects ppvDetails, ppvTiles or ppvHidden; Key identifies the name-tree entry independently of FileName, Prefix holds a collection subitem display prefix, and InitialDocument selects an item Key

RichMedia declarations

DeclarationPublic fields
TPdfRichMediaAssetName: string, MimeType: string, Data: TBytes, IsExternal: Boolean, ActivationCondition: string, DefaultView: string
TPdfRichMediaAssetsDynamic array of TPdfRichMediaAsset
TPdfRichMediaExtractedName: string, MimeType: string, Size: Int64, Sha256: string
TPdfRichMediaExtractedArrayDynamic array of TPdfRichMediaExtracted

Backend interfaces

InterfaceMethodPurpose
IPdfColourTransformfunction Transform(const Source: TPdfColourBuffer; TargetSpace: TPdfColourSpace; const TargetProfile: TBytes; out Target: TPdfColourBuffer): BooleanConverts a validated source buffer to the requested color space and profile
IPdfColourFloatTransformfunction TransformFloat(const Source: TPdfColourBuffer; TargetSpace: TPdfColourSpace; const TargetProfile: TBytes; TargetBitsPerComponent: Integer; out Target: TPdfColourBuffer): BooleanOptional interface since v3.312.0 for three native-endian IEEE 754 Single PCS Lab values per pixel in physical Lab units, with no source profile and explicit 8/16-bit target precision; the base interface and ConvertPdfColourBuffer retain integer input
IPdfFontSubsetBackendfunction Subset(const FontProgram: TBytes; const Glyphs: TPdfGlyphInfos; out SubsetProgram: TBytes): BooleanBuilds a font program containing the requested glyph closure
IPdfRegexEnginefunction FindMatches(const Text, Pattern, Replacement: WideString; MaxMatches: Integer): TPdfRegexMatchesReturns bounded regular-expression matches and replacement text
IPdfBarcodeProviderfunction Generate(Kind: TPdfBarcodeKind; const Text: string; ModuleSize: Double; out Rects: TPdfBarcodeRects): BooleanGenerates barcode module rectangles for a supported symbology
function Recognise(const Pixels: TBytes; Width, Height, Stride: Integer; MaxResults: Integer): TPdfBarcodeResultsRecognises bounded barcode results from a caller-owned pixel buffer

Default option factories

MemberPurpose
class function TPdfColourConversionOptions.Default: TPdfColourConversionOptionsReturns bounded color conversion defaults with source preservation enabled
class function TPdfFontSubsetOptions.Default: TPdfFontSubsetOptionsReturns bounded font and glyph limits with a minimum saving threshold; since v3.207.0 the actual saving percentage is rounded down before comparison, so a nonempty subset cannot satisfy a 100% threshold

Top-level routines

SignatureDescription
function ConvertPdfColourBuffer(const Source: TPdfColourBuffer; TargetSpace: TPdfColourSpace; const TargetProfile: TBytes; Transform: IPdfColourTransform; const Options: TPdfColourConversionOptions; out Target: TPdfColourBuffer; out OutputIntent: TPdfOutputIntent; out Report: TPdfColourConversionReport): BooleanRuns a color buffer through a caller transform and builds matching OutputIntent data while preserving the source on failure
function SubsetExistingPdfFont(const FontProgram: TBytes; const UsedGlyphs: TPdfGlyphInfos; Backend: IPdfFontSubsetBackend; const Options: TPdfFontSubsetOptions; out ResultProgram: TBytes; out GlyphClosure: TPdfGlyphInfos; out Report: TPdfFontSubsetReport): BooleanNormalizes requested glyphs, obtains dependencies from an optional IPdfFontSubsetClosureBackend, and accepts a smaller program only within the declared budgets
function ParsePdfSvgPath(const Data: string; MaxCommands: Integer = 100000): TPdfSvgPathCommandsParses bounded move, line, cubic, quadratic, and close commands with relative-coordinate support
function ExportPdfSvgPath(const Commands: TPdfSvgPathCommands): stringSerializes path commands to absolute SVG path syntax
procedure TransformPdfSvgPath(var Commands: TPdfSvgPathCommands; A, B, C, D, E, F: Double)Applies an affine matrix to every coordinate in a parsed SVG path
function BuildStyledRegexReplacementPlan(const Spans: TPdfStyledSpans; const Pattern, Replacement: WideString; Engine: IPdfRegexEngine; MaxCharacters: Integer = 16 * 1024 * 1024; MaxMatches: Integer = 100000): TPdfStyledReplacementsMaps regular-expression matches back to styled page-object spans and selects native or redaction-based replacement
function MergePdfXfaDatasets(const Packets: TXfaPacketList; const Bindings: TPdfXfaBindings; MaxPacketBytes: Integer = 32 * 1024 * 1024): TXfaPacketListMerges escaped SOM leaf bindings into UTF-8 datasets, supports Unicode XML element names in SOM paths, and preserves every untouched XFA packet
function RewritePdfXfaPacketStreams(Source, Destination: TStream; const Packets: TXfaPacketList; MaxTotalPacketBytes: Int64 = 256 * 1024 * 1024): BooleanAppends transactionally replaced XFA packet streams to an unencrypted PDF
function GeneratePdfBarcode(Kind: TPdfBarcodeKind; const Text: string; ModuleSize: Double; Provider: IPdfBarcodeProvider = nil): TPdfBarcodeRectsGenerates built-in Code 128-B vectors and delegates two-dimensional symbologies to a provider
function RecognisePdfBarcodes(const Pixels: TBytes; Width, Height, Stride: Integer; Provider: IPdfBarcodeProvider; MaxResults: Integer = 256): TPdfBarcodeResultsDelegates barcode recognition while enforcing image geometry and result bounds
procedure ValidatePdfPortfolio(const Portfolio: TPdfPortfolio; MaxItems: Integer = 100000; MaxEmbeddedBytes: Int64 = 1024 * 1024 * 1024)Validates field definitions, values, item counts, and embedded payload budgets
procedure SortPdfPortfolio(var Portfolio: TPdfPortfolio)Creates a deterministic Collection view by applying the configured sort keys in order with stable ties, using SortFields when present and the legacy single-field pair otherwise
function ExtractPdfRichMediaAssets(const Assets: TPdfRichMediaAssets; const OutputDirectory: string; MaxAssetBytes: Int64 = 256 * 1024 * 1024; MaxTotalBytes: Int64 = 1024 * 1024 * 1024): TPdfRichMediaExtractedArrayWrites embedded assets without executing content, resolving external references, or permitting directory escape

FPdfBarcodeZXing supplies an optional barcode generation and recognition provider

Safety model

Color and font input budgets are checked before allocating preservation copies; the source ICC profile is also subject to the color input byte limit

SVG parsing rejects non-finite coordinates after relative-coordinate arithmetic, and TransformPdfSvgPath validates a private candidate before replacing the caller array, preserving both the input and its aliases on failure

RichMedia extraction rejects path separators, control characters, Windows reserved device names, and trailing periods or spaces, and creates each output exclusively so an existing file cannot be truncated between validation and creation

If extraction fails, cleanup includes the currently written file and earlier files created by that call; the caller must keep the output directory under its control throughout extraction

Platform codecs, color engines, font subsetters, regular-expression engines, matrix barcode libraries, and recognizers are explicit interfaces so hosts can select their audited backend

FPdfStyledEdit executes these plans against a verified source snapshot with preview, font reuse or explicit fallback, bounded fitting and transactional save/reopen verification