Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
12.1
12.2
12.3
12.4
12.5
13.0
13.1
13.2
13.3
13.4
Statistic
FMM
Blog
Draws an annotation or form field on the current open page.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
DynaPDF | 10.0 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameter | Description | Example |
---|---|---|
The PDF reference returned from DynaPDF.New. | ||
Field | The field index or annotation index. Field name doesn't work. |
"FirstName" |
Returns OK or error.
See also FlattenAnnotOrField function in DynaPDF manual.
Sets a text field and flatterns it
# Gets passed PDF number, field name, value and an action (Flatten or empty)
#
# Get variables
Set Variable [ $pdf ; Value: GetValue ( Get ( ScriptParameter ) ; 1 ) ]
Set Variable [ $fieldname ; Value: GetValue ( Get ( ScriptParameter ) ; 2 ) ]
Set Variable [ $value ; Value: GetValue ( Get ( ScriptParameter ) ; 3 ) ]
Set Variable [ $action ; Value: GetValue ( Get ( ScriptParameter ) ; 4 ) ]
#
# Set text for the field
Set Variable [ $SetError ; Value: MBS( "DynaPDF.SetTextFieldValueEx" ; $pdf; $fieldname; $value ) ]
If [ $action = "Flatten" ]
# query, which page the field is on, so we can edit that page, required for drawing
Set Variable [ $page ; Value: MBS( "DynaPDF.GetField"; $pdf; $fieldname; "page") ]
If [ $page > 0 ]
Set Variable [ $EditError ; Value: MBS( "DynaPDF.EditPage"; $pdf; $page) ]
If [ $EditError = "OK" ]
# We loop over the fields on the page to find the right one
Set Variable [ $PageFieldCount ; Value: MBS( "DynaPDF.GetPageFieldCount"; $pdf ) ]
Set Variable [ $PageFieldIndex ; Value: 0 ]
Set Variable [ $found ; Value: 0 ]
If [ $PageFieldIndex < $PageFieldCount ]
Loop
# check name
Set Variable [ $Name ; Value: MBS( "DynaPDF.GetPageField"; $pdf; $PageFieldIndex; "name" ) ]
If [ $Name = $fieldname ]
# found the field to flatten
Set Variable [ $FlattenError ; Value: MBS("DynaPDF.FlattenAnnotOrField"; $pdf; $PageFieldIndex) ]
Set Variable [ $found ; Value: 1 ]
Exit Loop If [ 1 ]
End If
#
# next
Set Variable [ $PageFieldIndex ; Value: $PageFieldIndex + 1 ]
Exit Loop If [ $PageFieldIndex ≥ $PageFieldCount ]
End Loop
End If
Set Variable [ $r ; Value: MBS( "DynaPDF.EndPage"; $PDF; $page) ]
If [ not $found ]
Exit Script [ Text Result: "Field not found!" ]
Else
Exit Script [ Text Result: $FlattenError ]
End If
Else
Exit Script [ Text Result: $EditError ]
End If
End If
End If
Exit Script [ Text Result: $SetError ]
This function checks for a license.
Created 9th January 2020, last changed 18th November 2022