Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
Finds text using the parser.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
DynaPDF | 14.0 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameter | Description | Example | Flags |
---|---|---|---|
The PDF reference. | |||
Text | The text to find. | ||
SearchType | The search type. Can be a combination of Default, MatchAlways, WholeWord, CaseInSensitive or CaseSensitive. |
"CaseInSensitive, WholeWord" | |
ContinueSearch | Whether to start fresh (False) or continue search (true). | 0 | |
Left | The left coordinate of the rectangle. | 0 | Optional |
Bottom | The bottom coordinate of the page. | 0 | Optional |
Right | The right coordinate of the page. | 595 | Optional |
Top | The top coordinate of the page. | 842 | Optional |
Returns OK or error.
Text | Number | Description |
Default | 0 | Case sensitive search |
WholeWord | 1 | Only whole words |
CaseInSensitive | 2 | Case insensitive search |
MatchAlways | 4 | Return on every single character. Text is ignored when this flag is set. |
Perform find and replace:
# initialize parser
Set Variable [ $OptimizeFlags ; Value: 0 ]
Set Variable [ $r ; Value: MBS( "DynaPDF.Parser.Create"; $pdf; $OptimizeFlags ) ]
Set Variable [ $r ; Value: MBS( "DynaPDF.Parser.SetAltFont"; $pdf; "Helvetica"; 0; 12) ]
#
# Now parse a page
Set Variable [ $r ; Value: MBS("DynaPDF.Parser.ParsePage"; $pdf; 1; "EnableTextSelection") ]
If [ MBS("IsError") ]
Show Custom Dialog [ "Failed to parse page" ; $r ]
Else
# Run a find
Set Variable [ $continueFind ; Value: 0 ]
Set Variable [ $r ; Value: MBS( "DynaPDF.Parser.FindText"; $pdf; DynaPDF Replace Text::SearchText; "CaseInsensitive"; $continueFind) ]
If [ $r = 1 ]
Loop [ Flush: Always ]
# Do the replace
Set Variable [ $r ; Value: MBS( "DynaPDF.Parser.ReplaceSelText"; $pdf; DynaPDF Replace Text::ReplaceText) ]
#
# Continue search
Set Variable [ $continueFind ; Value: 1 ]
Set Variable [ $r ; Value: MBS( "DynaPDF.Parser.FindText"; $pdf; DynaPDF Replace Text::SearchText; "CaseInsensitive"; $continueFind) ]
Exit Loop If [ $r ≠ 1 ]
End Loop
#
# Save changes back
Set Variable [ $r ; Value: MBS( "DynaPDF.Parser.WriteToPage"; $pdf; $OptimizeFlags) ]
End If
End If
This function checks for a license.
Created 23th November 2023, last changed 14th December 2023