DynaPDF.FlattenForm
-------------------

Flatten forms.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [DynaPDF](component_DynaPDF.md) | [4.2](newinversion42.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "DynaPDF.FlattenForm"; PDF ) 

**MBS**( **"DynaPDF.FlattenForm";** /\* Flatten forms. \*/  
**$PDF**) /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |

### Result

Returns OK or error message.

### Description

Flatten forms.  
Draws all form fields on the corresponding pages and deletes the form fields, incl. corresponding JavaScripts and JavaScript actions. The resulting PDF pages look after flattening as if the form were printed.  
Note that this function does not support XFA forms. If the form is a hybrid form, the PDF form fields will be flattened. A maybe existing XFA form will be deleted but not flattened.  
Fields, which are invisible for printing, due to an absent print flag, or if the hidden flag was set, are excluded from flattening. These fields are deleted without drawing them on the page.  
This function is especially useful if a large amount of Interactive Forms (which are already filled out by the user) should be prepared for printing, or if the forms should be archived without allowing further changes. Flattened forms require less disk space and can be printed faster.  
  
XFA Forms which are created by Adobe's Designer are not fully supported. Only hybrid forms can be flatted.  
  
Requires DynaPDF Pro license.  
See also [FlattenForm](https://www.monkeybreadsoftware.com/DynaPDF-Manual/FlattenForm.shtml) function in DynaPDF manual.

### Examples

Make all forms flat:

 MBS ( "DynaPDF.FlattenForm"; $PDF )  
Flatten annotations and form fields:

 # Initialize DynaPDF if needed   
If \[ MBS ("[DynaPDF.IsInitialized](DynaPDFIsInitialized.md)") ≠ 1 \]   
 Perform Script \[ Specified: From list ; “InitDynaPDF” ; Parameter: \]  
End If  
\#   
\# New PDF environemnt   
Set Variable \[ $pdf ; Value: MBS ("[DynaPDF.New](DynaPDFNew.md)") \]   
\# Load PDF from container   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.OpenPDFFromContainer](DynaPDFOpenPDFFromContainer.md)"; $pdf ; MyTable::Input PDF) \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.ImportPDFFile](DynaPDFImportPDFFile.md)"; $pdf ; 1) \]   
\# Flatten annotations   
Set Variable \[ $r ; Value: MBS ( "[DynaPDF.FlattenAnnots](DynaPDFFlattenAnnots.md)"; $PDF ) \]   
\# and the form fields   
Set Variable \[ $r ; Value: MBS ( "DynaPDF.FlattenForm"; $PDF ) \]   
\# Save   
Set Field \[ MyTable::Output PDF ; MBS ("[DynaPDF.Save](DynaPDFSave.md)"; $pdf ; "Merged.pdf") \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.Release](DynaPDFRelease.md)"; $pdf ) \]  
### See also

- [DynaPDF.FlattenAnnots](DynaPDFFlattenAnnots.md)
- [DynaPDF.ImportPDFFile](DynaPDFImportPDFFile.md)
- [DynaPDF.Initialize](DynaPDFInitialize.md)
- [DynaPDF.IsInitialized](DynaPDFIsInitialized.md)
- [DynaPDF.New](DynaPDFNew.md)
- [DynaPDF.OpenPDFFromContainer](DynaPDFOpenPDFFromContainer.md)
- [DynaPDF.Release](DynaPDFRelease.md)
- [DynaPDF.Save](DynaPDFSave.md)

### Blog Entries

- [MBS Filemaker Plugin, version 4.2pr1](https://www.mbsplugins.de/archive/2014-04-02/MBS_Filemaker_Plugin_version_4/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 29th October 2020

  
[DynaPDF.FlattenAnnots](DynaPDFFlattenAnnots.md) - [DynaPDF.FlushPages](DynaPDFFlushPages.md)

[HTML Version](DynaPDFFlattenForm.shtml)