Include FPdfStyledEdit and supply an IPdfRegexEngine to plan and apply replacements to native top-level text objects
PlanStyledPdfRegexReplacements takes a reproducible source snapshot, joins actual Unicode glyphs in page/object order and maps matches back to stable object anchors; extraction-generated spaces and line breaks are omitted
Before altering a separately loaded document, ExecuteStyledPdfReplacements checks snapshot SHA-256, current source identity, anchors and nonoverlapping ranges
Identity is derived from reproducible serialisation with normalised timestamps and identifiers, rather than original file bytes; the plan keeps the actual snapshot bytes and their SHA-256
TPdfStyledEditPlan is the planning result: SourceBytes holds the captured reproducible snapshot, SourceSha256 its lowercase hex SHA-256, Spans the per-object anchors built from concatenated glyph text, and Replacements the planned edit intervals mapped onto those anchors
Where possible, native fonts, sizes, colours and matrices are reused; a match spanning objects or pages takes the first object's style and consumes matched characters in later objects without disturbing remaining text or page order
If native Unicode cannot be reproduced, FallbackFontName explicitly chooses a standard PostScript font; ForceFallbackFont selects that route directly
Fallback retains painter order, matrix, rendering mode and fill/stroke attributes; clipped, transparent, marked or tagged objects are refused instead of having their graphics semantics silently discarded
When replacement text exceeds its source width, an upright, nonsheared matrix may be scaled horizontally; MinHorizontalScale defaults to 0.5, whilst narrower text keeps the original matrix
This is a single-line replacement workflow with limited horizontal fitting; it neither walks nested Form XObjects nor rewrites Tagged PDF semantics or reflows paragraphs
Signed or encrypted input and XFA are refused; cancellation, obsolete plans, invalid UTF-16, unsupported fonts and exhausted allowances leave the caller's document intact
An optional CancellationToken of type IPdfCancellationToken is polled at each page, object and replacement step; a cancelled token raises EPdfOperationCancelled and keeps the caller document unchanged
PreviewOnly returns separately reopened output in PreviewPdf without replacing the caller's document; committing replaces it only after saving and reopening have verified glyph extraction and page count
Matches are combined into each object's final text before native objects change; fitting and minimum scale are tested once against original bounds, avoiding excessive shrinkage from repeated matches
An empty replacement removes a fully consumed text object after all anchored edits; multiple replacements are applied backwards to keep earlier source offsets valid
TPdfStyledEditOptions carries the budgets and behaviour switches shared by planning and execution; MaxDocumentBytes bounds the snapshot captured from the document, and MaxTextScanWork is the Int64 budget of native character visits and UTF-16 planning-copy units charged whilst extracting glyph text
Defaults allow 256 MiB of document data, 10,000 pages, 100,000 text objects, 16,777,216 UTF-16 units and 100,000 replacements; scanning allows 67,108,864 native-character visits and UTF-16 planning-copy units
Hard limits retain these page, object, character and replacement ceilings, permit 512 MiB of document data and 1,073,741,824 scan visits, and limit fallback font names to 1,024 bytes
Reporting includes source/output SHA-256, replacement, fallback and scaling totals, and each object's original/final text and PDF user-space bounds in points; page and object indexes are zero-based source indexes
TPdfStyledEditReport records the outcome; Changes is a TPdfStyledObjectChanges dynamic array holding one TPdfStyledObjectChange per rewritten or removed text object
In each TPdfStyledObjectChange, HorizontalScale is 1 when no fitting was applied and otherwise the applied width scale, and FontFallback is True when the object was rebuilt on the selected fallback font rather than its native one
Text replacement is not a security redaction process; sensitive content and associated document data must be removed through the dedicated redaction APIs
Options := TPdfStyledEditOptions.Default; Plan := PlanStyledPdfRegexReplacements(Pdf, Pattern, Replacement, Engine, Options); Options.PreviewOnly := True; if not ExecuteStyledPdfReplacements(Pdf, Plan, Options, PreviewPdf, Report) then raise EPdfProduction.Create(Report.ErrorMessage);
For measured mixed-style paragraph wrapping and alignment, turn to FPdfParagraphEdit
Set ExpandNestedForms True before planning and keep the option unchanged through execution; the staged document expands supported Form instances into independent page objects, keeping painter order and transformed positions intact
Preparation merges supported local page streams before expansion, so repeated instances keep their original saved object order across content-stream boundaries
Origins holds TPdfStyledObjectOrigin records indexed by zero-based PageIndex and expanded ObjectIndex; OriginalObjectIndex names the original top-level object, and FormPath lists zero-based child indexes down through the original nested Form hierarchy
Non-Form objects carry an empty FormPath; instance paths and every origin are verified once more during execution, so a modified source path rejects the plan
Use Origins to pick or drop replacement intervals for a single repeated instance before execution; every supported Form in the independent result is expanded, unchanged instances included
The preparation profile calls for untagged content, local supported content filters, finite nonsingular Form matrices, verified opaque painting states and supported text/path/image children; optional layers, unsupported clipping or graphics states and ambiguous content are refused
Each expanded page is compared before and after preparation at one pixel per PDF point; MaxFormDepth defaults to 32 with a hard maximum of 128, and MaxFormObjects defaults to 100,000 with a hard maximum of 1,000,000
MaxExpansionPixels defaults to 16,777,216 against a hard maximum of 268,435,456, and likewise bounds the spacing-restoration pixel references; a single execution shares this overall budget between Form preparation and affected-page verification
ExpandedNestedForms records the plan mode and ExpandedFormCount reports a successful expansion; the usual snapshot/hash, native reopen and preview/commit policy continues to apply
PlanStyledPdfMarkedText captures a TPdfMarkedTextEditPlan carrying SourceBytes, SourceSha256, PageIndex, ObjectIndex, the source Mcid, BeforeText and a nonempty AfterText
ExecuteStyledPdfMarkedText edits that top-level native text object without rebuilding its font or text state; the source font has to reproduce the requested Unicode, and fallback-font options are refused in this workflow
For a unique MCID, marks are detached without altering shared property dictionaries, then independently restored with the same tag names, MCID and language values; any existing content ActualText follows the complete replacement text
The target takes one to sixteen printable ASCII tag names, at most three parameters per mark, and only an integer MCID plus string Lang/ActualText; precisely one MCID must appear across the target marks
Version 3.207.1 also accepts a contiguous group of top-level text objects with identical native mark identities and stacks, provided neither the content marks nor the bound structure leaf owns ActualText; the selected object changes in place whilst the original shared marks stay attached
Independent output reopening verifies the group membership and every peer text object, along with the common mark values and page pixels; a separate content sequence reusing the same MCID, a differing nested mark stack or a nontext peer is refused
Where a structure tree already exists, the MCID has to map to a single leaf element with a single page content binding; roles, titles, alternate text and language stay untouched, and an existing leaf ActualText value is refreshed after native serialisation
Explicit stream MCR references, ancestor ActualText, shared groups with content or leaf ActualText, unsupported mark parameters, empty replacement text, expansion of tagged Forms, clipping and transparent target text all call for a separate reviewed profile and are refused
This API keeps the original native text object and offers the same bounded horizontal fitting; it creates no new MCIDs, rewrites no ParentTree ownership and infers no semantic content
The finished output is independently reopened to check the replacement Unicode, retained mark values and structure bindings, and is then compared against the edited native page at one pixel per PDF point
Since v3.289.0, ExecuteStyledPdfMarkedText captures the complete original page declaration sequence through ReadPageContentSemanticFrame. Native regeneration still supplies font encoding and object graphics, whilst the restored source sequence keeps empty declarations, generic empty MCIDs, named-property occurrences, nested scope coverage, point marks and empty property values
Only the selected object's ActualText is updated. A native ActualText scope covering other native objects requires a complete group replacement and rejects this single-object workflow. Unchanged declarations, MCIDs, language and explicit alternatives keep their original values and coverage; matching top-level object count and types are required
Inline image peers are promoted to ordinary image XObjects by keeping their encoded data and expanding inline dictionary abbreviations, without rasterising them. Source declarations and pixels are checked before the text edit; PromotedInlineImageCount reports the actual promotions. Original Form streams, repeated peers included, remain separate unchanged resources
The final candidate is reopened and checked for every retained declaration's pairing, source boundary, property presence and value, along with object order/types, native text, structure metadata and rendered pixels. Preview leaves the live document unchanged; stale/forged plans, cancellation, work limits or failed reproduction return no candidate
The semantic-frame source and per-stream limits apply in addition to styled-edit work/output limits. This qualifies supported top-level marked-object edits through actual regeneration and save/reopen. Paragraph/group transformations, direct SetText/UpdatePage calls, edited Form descendants and reused internal structure normalisation remain separate completion work
A nondefault horizontal text scale or rise also triggers native saved-page pixel verification; unsupported serialisation yields no output
Native page content generation may leave out Tc and Tw, including on unchanged neighbouring text; edited pages carrying nonzero spacing keep the original values by way of bounded source/generated text-operator correspondence
The parser follows q/Q state together with ordinary Tj/TJ and quote showing operators, empty strings and numeric-only arrays without native objects included, and generated content is rewritten with local per-object spacing ahead of publication
Deleted objects drop out of the correspondence, and cross-page edits hold a native pixel reference before each affected scene is unloaded; final-file pages have to match those references exactly at the declared resolution
Spacing restoration calls for matching top-level native text and showing-operator counts, balanced text/graphics scopes and complete operands in every local content stream; marked editing refuses ambiguous correspondence
Content decoding, token visits, restoration and native glyph visits draw on the shared MaxTextScanWork; decoded/local stream staging and the final output also answer to MaxDocumentBytes
Ordinary replacement takes extra pixel references for surviving nonzero spacing and falls back on strict native-pixel verification where inline images or unmatched source operators stand in the way of correspondence; a native serialisation mismatch rejects the output, marked edits always verify their final page, and individual native calls stay synchronous
Rejected output clears the applied, fallback, scaling and expansion publication counts along with the output digests; should commit loading fail, the caller's document is restored
PlanStyledPdfObjectEdits captures an exact source snapshot and copies a bounded operation list and semantic revisions. ExecuteStyledPdfObjectEdits applies the batch to a private document, generates native content once and publishes the independently verified result through the existing preview or commit contract
With the default Target = poetPageObjects, operations address original zero-based page object indexes. poekProperties uses TPdfPageObjectInfo and an explicit Changes set for matrix, fill/stroke colours, stroke width, line join/cap or dash pattern. Deactivation requires an explicit removal operation instead. poekText replaces one text object's nonempty single-line UTF-16 using its original font, with native glyph readback and no implicit fitting or fallback
poekRemove removes a source object from page membership. poekInsertText inserts nonempty single-line text at an original object boundary, from zero through the original object count, using explicit FontName and FontSize. An optional Properties.HasMatrix sets its page matrix and Properties.HasFillColor sets its fill colour/alpha; other insertion attributes keep native defaults. Multiple insertions at one boundary follow operation-list order
Source indexes stay stable throughout the batch. Properties and text may be updated sequentially before removal, whilst another operation on an already removed source is rejected. Insertions use source boundaries rather than shifting object indexes. The plan independently copies dash arrays and semantic revision arrays, and clears caller-owned native handles
BoundaryAffinity places every original declaration at an insertion boundary either before the inserted objects (pobaBeforeInsertion, the default) or after them (pobaAfterInsertion). Removed objects collapse their boundaries without deleting declarations. Original BMC/BDC/EMC and MP/DP occurrence order, pairing and unrelated property values remain intact, including empty groups and ordinary empty MCIDs
SemanticPolicy=pospRejectChanges is the conservative default: text or membership changes require explicit authorisation when the page declarations or reachable structure graph contain ActualText, Alt or E values. Property changes keep these values. pospPreserveValues explicitly keeps existing values during text/membership changes. pospReviewedValues applies caller-specified revisions and intentionally preserves unlisted values; the library does not infer replacement speech or certify human review
Each TPdfObjectSemanticEdit names one existing ActualText, Alt or E value. postContentMark uses the original complete declaration-frame index, including empty and point declarations; postStructureNode uses an existing reachable StructElem object number. Duplicate revisions, missing keys, unsupported keys, invalid UTF-16 and NUL are rejected. Empty values remain present; supplementary Unicode is written as UTF-16BE without a platform-codepage conversion
Structure revisions replace only those values through a sparse update. Page identities and StructParents keys, the structure root, every reachable structure/ParentTree object and all unapproved metadata remain unchanged. By default this workflow preserves existing ownership; it does not certify or repair an arbitrary source tree. Explicit stream MCR normalisation remains outside this profile
Since v3.370.0, RemoveEmptiedStructureNodes also removes an element that the peer removal left without content items or children; removal proceeds deepest first and stops at the root, and an element that still carries children or other content stays. The default False keeps the emptied element, so its role, language and semantic values survive
Since v3.368.0, RemoveOwnedStructurePeers opts out of that preservation for removed content. When it is True, a labelled mark whose complete content is being removed also leaves the page content stream, and the structure content items that only that mark owned are removed through the structure editor, which also clears their ParentTree entry. A mark that also wraps surviving content stays untouched, a page that reuses the removed MCID for surviving content is rejected, and the saved structure is re-read to prove that element identities, roles, children and every surviving content item are unchanged. The default False keeps the released collapse-to-boundary behaviour
Encoded inline image peers are promoted without rasterisation and compared with original page pixels before editing. Form invocations remain opaque native objects: their page matrices can be changed independently, including a shared Form invoked on another page, whilst internal text/tag editing and reused internal structure normalisation remain separate work
After native generation, temporary per-object slot declarations prove serialised identity before painter-order restoration; they are removed before original declarations return. Reopen verifies every source declaration and mapped coverage, object matrices/colours/stroke properties, pre-substitution glyph text, the full edited page and original foreign-page pixels at one pixel per PDF point. Empty dash patterns may normalise their unused phase
SourceObjectMap maps every original object to its final index or -1 after removal. OperationObjectMap maps each operation to its final object, inserted text included, or -1 if its source was removed. SemanticBoundaryMap includes every original object boundary and the after-page boundary. Reports also expose applied operation, preserved declaration and promoted image counts, source/output hashes and failure text; failures clear publication maps and counts and leave the caller unchanged
Since v3.292.0, no-insertion batches restore existing font-resource bindings before glyph verification, preserving same-family horizontal/vertical font dictionaries. ScanWork reports charged scan/copy work on success and failure, and execution errors identify the failed phase; this work budget does not bound native execution time or allocation
The workflow accepts at most 4096 source/output objects, operations and semantic revisions, subject to smaller inherited edit limits. Semantic revision text is bounded by 1,048,000 aggregate UTF-16 units and the inherited character budget; frame source/decoded/property limits still apply. The inherited expansion-pixel budget covers original page references plus the edited-page reference for the entire document, and cancellation/work checks cover bounded scans and copies; native execution isolation is a separate capability
Signed, encrypted and XFA documents, expanded Form sources, unsupported source operators and sources without provable native correspondence remain excluded. Low-level direct mutations outside this batch keep their existing behaviour. Object removal edits page membership; secure redaction uses its separate sensitive-resource cleanup workflow
Delphi and FPC Win64 evidence covers 24 successful and 21 rejection profiles, three actual full-save/edit generations per successful case, 72 independently inspected outputs and 216 pages, including cases that remove the content and the structure peer it owned, with and without removing the element left empty. Independent parsing derives insertion/removal maps from fixture operations, checks original/reviewed declaration values and the complete structure graph, verifies actual text/style changes and keeps shared Form payloads
type
TPdfObjectEditKind=(poekProperties,poekText,poekRemove,poekInsertText);
TPdfObjectEditTarget=(poetPageObjects,poetFormInstance);
TPdfObjectBoundaryAffinity=(pobaBeforeInsertion,pobaAfterInsertion);
TPdfObjectSemanticPolicy=(pospRejectChanges,pospPreserveValues,pospReviewedValues);
TPdfObjectSemanticTarget=(postContentMark,postStructureNode,postPageContentMark);
TPdfObjectEditOperation=record
Kind:TPdfObjectEditKind;
ObjectIndex:Integer;
Properties:TPdfPageObjectInfo;
Changes:TPdfPageObjectChanges;
Text,FontName:WideString;
FontSize:Single;
end;
TPdfObjectEditOperations=array of TPdfObjectEditOperation;
TPdfObjectSemanticEdit=record
Target:TPdfObjectSemanticTarget;
Index:Integer;
Key:AnsiString;
Value:WideString;
end;
TPdfObjectSemanticEdits=array of TPdfObjectSemanticEdit;
TPdfObjectEditOptions=record
EditOptions:TPdfStyledEditOptions;
Target:TPdfObjectEditTarget;
FormObjectIndex:Integer;
FormPath:TPdfStyledFormPath;
BoundaryAffinity:TPdfObjectBoundaryAffinity;
SemanticPolicy:TPdfObjectSemanticPolicy;
RemoveOwnedStructurePeers:Boolean;
RemoveEmptiedStructureNodes:Boolean;
class function Default:TPdfObjectEditOptions;static;
end;
TPdfObjectEditPlan=record
SourceBytes:TBytes;
SourceSha256:string;
Target:TPdfObjectEditTarget;
FormObjectIndex:Integer;
FormPath:TPdfStyledFormPath;
FormSourceBytes:TBytes;
FormStructurePreserved:Boolean;
FormStreamObjectNumber,FormStreamGeneration,FormParentTreeKey:Integer;
FormSourceSha256:string;
PageIndex:Integer;
Operations:TPdfObjectEditOperations;
SemanticEdits:TPdfObjectSemanticEdits;
BoundaryAffinity:TPdfObjectBoundaryAffinity;
SemanticPolicy:TPdfObjectSemanticPolicy;
RemoveOwnedStructurePeers:Boolean;
RemoveEmptiedStructureNodes:Boolean;
end;
TPdfObjectEditReport=record
Succeeded,Cancelled,PreviewOnly:Boolean;
FormInstanceEdited:Boolean;
FormObjectIndex:Integer;
FormPath:TPdfStyledFormPath;
AppliedOperationCount,PreservedSemanticMarkCount,PromotedInlineImageCount:Integer;
RemovedStructurePeers,RemovedStructureNodes:Integer;
FormStructurePreserved:Boolean;
FormStreamObjectNumber,FormStreamGeneration,FormParentTreeKey:Integer;
SourceObjectMap,OperationObjectMap,SemanticBoundaryMap:TPdfIntegerArray;
ScanWork:Int64;
SourceSha256,OutputSha256,ErrorMessage:string;
end;
function PlanStyledPdfObjectEdits(Pdf:TPdf;PageIndex:Integer;
const Operations:TPdfObjectEditOperations;const SemanticEdits:TPdfObjectSemanticEdits;
const Options:TPdfObjectEditOptions):TPdfObjectEditPlan;
function ExecuteStyledPdfObjectEdits(Pdf:TPdf;const Plan:TPdfObjectEditPlan;
const Options:TPdfObjectEditOptions;out PreviewPdf:TBytes;out Report:TPdfObjectEditReport):Boolean;
Set Target = poetFormInstance and FormObjectIndex to one original zero-based top-level Form object on the selected page; the same planning and execution APIs then address that Form's direct child objects in its local coordinate system
Since v3.321.0, optional FormPath selects a deeper invocation: each entry is the zero-based direct-child Form object index inside the previously selected Form. Object indexes include text, paths and images; they are neither resource names nor Form-only ordinals. An empty path keeps the top-level behaviour, whilst operations and output maps address the deepest selected Form's direct children and local coordinates
Paths may contain at most Min(15, EditOptions.MaxFormDepth) entries, with every index below Min(4096, EditOptions.MaxTextObjects). Planning copies the caller's array; execution requires the same complete path and source identity. Page-object targets reject nonempty paths, and invalid, non-Form or excessive-depth selections publish no output
The operation list, insertion affinity and source/operation/boundary maps retain their existing meanings within the selected Form. Other Do invocations carry on using their original streams and resources, including calls on other pages; the page still contains one Form at the original painter position and outer placement matrix
For ordinary unowned resources, a private local page supplies native font encoding and object regeneration, and only the selected invocation is rebound to an independent Form with the original BBox and Matrix. The temporary page is removed from the final page tree; complete external structure and ParentTree ownership must remain unchanged apart from explicit reviewed values
For this target, postContentMark addresses a deepest local Form declaration, postPageContentMark addresses an original page declaration, and postStructureNode addresses an existing structure object number in the original source. Intermediate ancestor declarations retain their original values and boundaries; they are not exposed as additional reviewed-value targets. Text or membership changes with outer ActualText/Alt/E require an explicit preservation or reviewed-value policy; reviewed values may contain supplementary Unicode
FormSourceBytes and FormSourceSha256 bind the prepared local source used by the selected workflow in addition to the original document identity. Keep target, Form index, complete path, affinity and semantic policy unchanged between planning and execution. Successful reports set FormInstanceEdited and return independent copies of FormObjectIndex and FormPath; maps refer to deepest local direct children
Execution first forces an unmodified native materialisation and compares every original page, refusing inherited graphics states that the local rewrite cannot preserve. It then verifies the imported local declaration inventory and complete local pixels, original structure graph, unchanged outer matrix, all foreign pages and every pixel outside the selected Form's before/after bounds at one pixel per PDF point
Every selected ancestor is rebound independently whilst its BBox, Matrix, painter position, declarations and unselected calls remain intact. Recursive preparation and execution consume the remaining transaction scan-work budget; a failed level leaves the caller's original document unchanged
The ordinary cloning profile excludes Group, OC, external Ref and internal StructParent/StructParents ownership in the selected resource graph. Since v3.323.0, qualified unique internal ownership follows the identity-preserving workflow below. Unsupported inherited states, arbitrary ancestor-value revisions and semantic policies outside these batches remain separate requirements
A self-transformed Form with an offset BBox can keep the reader's existing clipped-source diagnostic before and after a successful edit; this does not certify previously unsupported native selection mappings. Complete reader ownership and logical order are checked where the source reader profile was already supported
Options := TPdfObjectEditOptions.Default; Options.Target := poetFormInstance; Options.FormObjectIndex := 0; SetLength(Options.FormPath, 2); Options.FormPath[0] := 0; Options.FormPath[1] := 1; Options.SemanticPolicy := pospPreserveValues; SetLength(Operations, 1); Operations[0].Kind := poekText; Operations[0].ObjectIndex := 0; Operations[0].Text := 'Revised text'; Plan := PlanStyledPdfObjectEdits(Pdf, 0, Operations, nil, Options); if not ExecuteStyledPdfObjectEdits(Pdf, Plan, Options, PreviewPdf, Report) then raise Exception.Create(Report.ErrorMessage);
The same poetFormInstance target automatically accepts a uniquely invoked internally tagged Form, or a unique ordinary container with internally owned resource peers. Use reviewed Form normalisation first for shared internal streams; unresolved sharing rejects rather than changing other invocations
Successful plans and reports set FormStructurePreserved and retain FormStreamObjectNumber, FormStreamGeneration and FormParentTreeKey. The key is -1 for an ordinary container whose descendants own the internal namespaces. The edited stream keeps its original object identity, BBox, Matrix and namespace; original MCR/ParentTree relationships and nonselected owned resource streams remain unchanged
Source-font text, properties, removal, insertion affinity and preview retain deepest-local indexes and maps. Local declarations and reviewed original page/structure values remain separate, including multiple values on one declaration or structure element. Page semantic revisions retain existing content-stream identities and explicit MCR Stm provenance; shared page streams require separate normalisation before those page revisions
Execution validates reciprocal structure bindings and unique actual source invocation counts, checks forced inherited-state materialisation, verifies complete local declarations and pixels after resource import, and compares every foreign-page and outside-selection pixel before publication. Owned resource identities survive native import, including nonselected internally tagged Form peers; temporary import pages and internal provenance metadata are removed
Removing an entire owned peer without an explicit structure repair, editing a stream also reachable through annotation appearances, stale or forged identities, exhausted budgets and unsupported source reproduction publish no candidate. Independent appearances remain supported. Owned Form paragraph reflow reuses this transaction since v3.324.0; arbitrary ancestor-value revisions, whole-object Form ownership and broader appearance/source normalisation remain separate capabilities
PlanStyledPdfOwnedFormContent creates a verified internal Form anchor for a specialised local content editor. ExecuteStyledPdfOwnedFormContent runs the caller-supplied IPdfStyledFormContentEditor through its single Execute method on the private local document, then retains the same source/path/namespace, structure, resource-ownership and publication checks as typed batches. The editor must commit its verified local output, obey the supplied remaining scan-work and cancellation limits, and return its consumed work and failure/cancellation details in TPdfObjectEditReport; a nil editor rejects
Since v3.326.0, an owned plan records FormPreparationWork for its bounded source selection, structure inspection and private snapshot preparation. This informational value lets owned paragraph inspection reserve the remaining scan-work budget; execution recomputes its own transaction work and reports it through ScanWork
type
TPdfStyledEditOptions= record
MaxDocumentBytes: Integer;
MaxPages, MaxTextObjects, MaxCharacters, MaxReplacements: Integer;
MaxTextScanWork: Int64;
MinHorizontalScale: Double;
ExpandNestedForms: Boolean;
MaxFormDepth, MaxFormObjects: Integer;
MaxExpansionPixels: Int64;
FallbackFontName: AnsiString;
ForceFallbackFont: Boolean;
PreviewOnly: Boolean;
CancellationToken: IPdfCancellationToken;
class function Default: TPdfStyledEditOptions; static;
end;
TPdfStyledFormPath= array of Integer;
TPdfStyledObjectOrigin= record
PageIndex, ObjectIndex, OriginalObjectIndex: Integer;
FormPath: TPdfStyledFormPath;
end;
TPdfStyledObjectOrigins= array of TPdfStyledObjectOrigin;
TPdfStyledEditPlan= record
SourceSha256: string;
SourceBytes: TBytes;
Spans: TPdfStyledSpans;
Replacements: TPdfStyledReplacements;
ExpandedNestedForms: Boolean;
Origins: TPdfStyledObjectOrigins;
end;
TPdfStyledObjectChange= record
PageIndex, ObjectIndex: Integer;
BeforeText, AfterText: WideString;
BeforeBounds, AfterBounds: TPdfRectangle;
HorizontalScale: Double;
FontFallback: Boolean;
end;
TPdfStyledObjectChanges= array of TPdfStyledObjectChange;
TPdfStyledEditReport= record
Succeeded, Cancelled, PreviewOnly: Boolean;
AppliedReplacementCount, FontFallbackCount, ScaledObjectCount: Integer;
ExpandedFormCount: Integer;
PromotedInlineImageCount: Integer;
SourceSha256, OutputSha256, ErrorMessage: string;
Changes: TPdfStyledObjectChanges;
end;
type
TPdfMarkedTextEditPlan= record
SourceBytes: TBytes;
SourceSha256: string;
PageIndex, ObjectIndex, Mcid: Integer;
BeforeText, AfterText: WideString;
end;
function PlanStyledPdfMarkedText(Pdf:TPdf; PageIndex,ObjectIndex:Integer;
const Replacement:WideString; const Options:TPdfStyledEditOptions):TPdfMarkedTextEditPlan;
function ExecuteStyledPdfMarkedText(Pdf:TPdf; const Plan:TPdfMarkedTextEditPlan;
const Options:TPdfStyledEditOptions; out PreviewPdf:TBytes;
out Report:TPdfStyledEditReport):Boolean;
function PlanStyledPdfRegexReplacements(Pdf: TPdf;
const Pattern, Replacement: WideString; Engine: IPdfRegexEngine;
const Options: TPdfStyledEditOptions): TPdfStyledEditPlan;
function ExecuteStyledPdfReplacements(Pdf: TPdf;
const Plan: TPdfStyledEditPlan; const Options: TPdfStyledEditOptions;
out PreviewPdf: TBytes; out Report: TPdfStyledEditReport): Boolean;