Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
DynaPDF.FlattenAnnotOrField
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 |
Parameters
Parameter | Description | Example |
---|---|---|
The PDF reference returned from DynaPDF.New. | ||
Field | The field index or annotation index. Field name doesn't work. |
"FirstName" |
Result
Returns OK or error.
Description
Draws an annotation or form field on the current open page.Form fields are annotations of type atWidget. The annotations of a page can be enumerated with DynaPDF.GetPageAnnotation and DynaPDF.GetPageAnnotCount.
The annotation or form field is deleted from the page's annotation array after it was flattened. If the function succeeds the return value is OK. If the function fails the return value is an error message.
See also FlattenAnnotOrField function in DynaPDF manual.
Examples
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 ]
See also
- DynaPDF.EditPage
- DynaPDF.EndPage
- DynaPDF.GetField
- DynaPDF.GetPageAnnotation
- DynaPDF.GetPageAnnotCount
- DynaPDF.GetPageField
- DynaPDF.GetPageFieldCount
- DynaPDF.SetFieldFlags
- DynaPDF.SetTextFieldValue
- DynaPDF.SetTextFieldValueEx
Release notes
- Version 13.0
- Fixed problem passing field index to DynaPDF.FlattenAnnotOrField function.
- Version 10.0
- Added DynaPDF.FlattenAnnotOrField function.
Blog Entries
- MBS FileMaker Plugin, version 12.6pr1
- New in the MBS FileMaker Plugin 10.0
- MBS FileMaker Plugin, version 10.0pr8
This function checks for a license.
Created 9th January 2020, last changed 18th November 2022