Add FPdfStyledEdit and provide an IPdfRegexEngine to plan and execute replacements against native top-level text objects
PlanStyledPdfRegexReplacements captures a reproducible source snapshot, concatenates actual Unicode glyphs in page and object order, and maps matches back to stable object anchors; generated extraction spaces and line breaks are excluded
ExecuteStyledPdfReplacements validates the snapshot SHA-256, current source identity, anchors and nonoverlapping intervals before changing an independently loaded document
The source identity uses reproducible serialization, including normalized timestamps and identifiers, rather than the original file bytes; the plan stores 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
Native font, text size, color and matrix are reused where possible; replacements spanning objects or pages retain the first object's style and remove consumed characters from later objects while preserving remaining text and page order
FallbackFontName explicitly selects a standard PostScript font when native Unicode cannot be reproduced; ForceFallbackFont requests that path directly
Fallback preserves painter order, matrix, rendering mode, fill and stroke attributes; clipped, transparent, marked or tagged objects are rejected rather than silently losing their graphics semantics
Text wider than its source bounds may shrink horizontally when its matrix is upright and nonsheared; MinHorizontalScale defaults to 0.5, with narrower replacement text retaining the original matrix
Regex replacement supports single-line text and bounded horizontal fitting, with optional safe nested Form expansion; the separate marked-text API maintains the supported existing semantics profile, while paragraph reflow is a separate workflow
Signed or encrypted documents and XFA are rejected; cancellation, stale plans, invalid UTF-16, unsupported fonts and exhausted budgets leave the caller document unchanged
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 the independently reopened result in PreviewPdf without replacing the caller; successful commit replaces the document only after glyph extraction and page count have been verified after saving and reopening
All matches are assembled into final object text before changing native objects; fitting and the minimum scale are checked once against original bounds, preventing repeated matches from accumulating excessive shrinkage
Empty replacement text removes a fully consumed text object after all anchored edits; multiple replacements run backward so earlier source offsets remain valid
TPdfStyledEditOptions carries the budgets and behavior 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 while extracting glyph text
Default limits are 256 MiB of document bytes, 10,000 pages, 100,000 text objects, 16,777,216 UTF-16 units and 100,000 replacements; the text-scan work budget is 67,108,864 native character visits and UTF-16 planning-copy units
Hard maxima retain those page, object, character and replacement limits, allow 512 MiB of document bytes and 1,073,741,824 scan visits, and bound a fallback font name to 1,024 bytes
The report includes source and output SHA-256 values, applied replacement, fallback and scaling counts, and per-object original/final text and bounds in PDF user-space 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
A replacement operation is not a security redaction workflow; use the dedicated redaction APIs for removal of sensitive content and associated document data
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, use FPdfParagraphEdit
Set ExpandNestedForms True before planning and keep the same option during execution; the staged document expands supported Form instances into independent page objects while retaining painter order and transformed positions
Preparation combines supported local page streams before expansion so repeated instances retain their original saved object order across content-stream boundaries
Origins contains TPdfStyledObjectOrigin records indexed by zero-based PageIndex and expanded ObjectIndex; OriginalObjectIndex names the original top-level object and FormPath lists zero-based child indexes through the original nested Form hierarchy
Non-Form objects have an empty FormPath; instance paths and all origins are checked again during execution, so modifying a source path rejects the plan
Use Origins to select or remove replacement intervals for one repeated instance before execution; all supported Forms in the independent result are expanded, including unchanged instances
The preparation profile requires untagged content, local supported content filters, finite nonsingular Form matrices, verified opaque painting states and supported text/path/image children; optional layers, unsupported clipping/graphics states and ambiguous content are rejected
Every expanded page is compared before and after preparation at one pixel per PDF point; MaxFormDepth defaults to 32 with hard maximum 128, MaxFormObjects defaults to 100,000 with hard maximum 1,000,000
MaxExpansionPixels defaults to 16,777,216 with hard maximum 268,435,456 and also bounds spacing-restoration pixel references; one execution shares this total budget across Form preparation and affected-page verification
ExpandedNestedForms records the plan mode, ExpandedFormCount reports successful expansion, and the ordinary snapshot/hash, native reopen and preview/commit policy still applies
PlanStyledPdfMarkedText captures a TPdfMarkedTextEditPlan with SourceBytes, SourceSha256, PageIndex, ObjectIndex, the source Mcid, BeforeText and nonempty AfterText
ExecuteStyledPdfMarkedText edits that top-level native text object without rebuilding its font or text state; the source font must reproduce the requested Unicode, and fallback-font options are rejected for this workflow
For a unique MCID, marks are detached without mutating shared property dictionaries, then independently restored with the same tag names, MCID and language values; existing content ActualText follows the complete replacement text
The target supports one to sixteen printable ASCII tag names, at most three parameters per mark and only integer MCID plus string Lang/ActualText; exactly one MCID must occur 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 while the original shared marks remain attached
Independent output reopening verifies the group membership and every peer text object, as well as 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 rejected
With an existing structure tree, the MCID must map to one leaf element with one page content binding; roles, titles, alternate text and language remain unchanged, and an existing leaf ActualText value is updated after native serialization
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 require a separate reviewed profile and are rejected
This API keeps the original native text object and supports the same bounded horizontal fitting; it does not create new MCIDs, rewrite ParentTree ownership or infer semantic content
Full output is independently reopened to check replacement Unicode, retained mark values and structure bindings, 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, while the restored source sequence retains 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 retain their original values and coverage; matching top-level object count and types are required
Inline image peers are promoted to ordinary image XObjects by retaining their encoded data and expanding inline dictionary abbreviations, without rasterizing them. Source declarations and pixels are checked before the text edit; PromotedInlineImageCount reports the actual promotions. Original Form streams, including repeated peers, remain separate unchanged resources
The final candidate is reopened and checked for every retained declaration's pairing, source boundary, property presence and value, as well as 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. Ordinary selected Form instances use the separate batch target below; direct SetText/UpdatePage calls and reused internal structure normalization retain their separate policies
Nondefault horizontal text scale and rise also trigger native saved-page pixel verification; unsupported serialization returns no output
Native page content generation can omit Tc and Tw, including on unchanged neighboring text; edited pages with nonzero spacing retain the original values through bounded source/generated text-operator correspondence
The parser tracks q/Q state, ordinary Tj/TJ and quote showing operators, including empty strings and numeric-only arrays without native objects, while generated content is rewritten with local per-object spacing before publication
Deleted objects are removed from correspondence and cross-page edits keep a native pixel reference before each affected scene is unloaded; final-file pages must match those references exactly at the declared resolution
Spacing restoration requires matching top-level native text and showing-operator counts, balanced text/graphics scopes and complete operands in each local content stream; marked editing rejects ambiguous correspondence
Content decoding, token visits, restoration and native glyph visits share MaxTextScanWork; decoded/local stream staging and final output also obey MaxDocumentBytes
Ordinary replacement uses additional pixel references for surviving nonzero spacing and falls back to strict native-pixel verification when inline images or unmatched source operators prevent correspondence; a native serialization mismatch rejects output, while marked edits always verify their final page and individual native calls remain synchronous
Rejected output clears applied, fallback, scaling and expansion publication counts and output digests; the caller's document is restored if commit loading fails
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 colors, 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 color/alpha; other insertion attributes retain native defaults. Multiple insertions at one boundary follow operation-list order
Source indexes remain stable throughout the batch. Properties and text may be updated sequentially before removal, while 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 authorization when the page declarations or reachable structure graph contain ActualText, Alt or E values. Property changes retain these values. pospPreserveValues explicitly retains 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 normalization 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 behavior
Encoded inline image peers are promoted without rasterization 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, while internal text/tag editing and reused internal structure normalization remain separate work
After native generation, temporary per-object slot declarations prove serialized identity before painter-order restoration; they are removed before original declarations return. Reopen verifies every source declaration and mapped coverage, object matrices/colors/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 normalize their unused phase
SourceObjectMap maps every original object to its final index or -1 after removal. OperationObjectMap maps each operation to its final object, including inserted text, 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 retain their existing behavior. 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 retains 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 retains the top-level behavior, while 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 continue 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 except for 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 materialization 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 while 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 retain 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 normalization 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 normalization before those page revisions
Execution validates reciprocal structure bindings and unique actual source invocation counts, checks forced inherited-state materialization, 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 normalization remain separate capabilities
PlanStyledPdfOwnedFormContent creates a verified internal Form anchor for a specialized 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;