DynaPDF.AddJavaScript
---------------------

Adds a global JavaScript to the PDF file.

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

MBS( "DynaPDF.AddJavaScript"; PDF; Name; JavaScript ) 

**MBS**( **"DynaPDF.AddJavaScript";** /\* Adds a global JavaScript to the PDF file. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$Name**; /\* The name for the JavaScript snippet.e.g. "test" \*/   
**$JavaScript**) /\* The JavaScript code. \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |
| Name | The name for the JavaScript snippet. | "test" |
| JavaScript | The JavaScript code. |  |

### Result

Returns the handle of the JavaScript or error.

### Description

Adds a global JavaScript to the PDF file.   
The parameter Name must be a unique name to identify the script in the user interface.  
Note that the name is NOT used to identify a function inside the JavaScript. The parameter Script must be a JavaScript function or a set of [JavaScript](component_JavaScript.md) functions. DynaPDF does not check whether the script is valid. A JavaScript is always stored unchecked and unchanged to the PDF file. The [JavaScript](component_JavaScript.md) functions inside a script can be used by JavaScript actions to enable parameterized function calls (see also [DynaPDF.CreateJSAction](DynaPDFCreateJSAction.md)).   
See also [AddJavaScript](https://www.monkeybreadsoftware.com/DynaPDF-Manual/AddJavaScript.shtml) function in DynaPDF manual.

### Examples

Add JavaScript:

 Set Variable \[ $r ; Value: MBS ("DynaPDF.AddJavaScript"; $pdf ; "test"; "function test() { return 123; }") \]  
### See also

- [DynaPDF.ChangeJavaScript](DynaPDFChangeJavaScript.md)
- [DynaPDF.CreateJSAction](DynaPDFCreateJSAction.md)
- [DynaPDF.GetJavaScript](DynaPDFGetJavaScript.md)
- [DynaPDF.GetJavaScriptName](DynaPDFGetJavaScriptName.md)
- [DynaPDF.New](DynaPDFNew.md)

### Release notes

- **Version 13.2**
    - Added [DynaPDF.AddJavaScript](https://www.mbsplugins.eu/DynaPDFAddJavaScript.shtml), [DynaPDF.ChangeJavaScript](https://www.mbsplugins.eu/DynaPDFChangeJavaScript.shtml), [DynaPDF.ChangeJavaScriptAction](https://www.mbsplugins.eu/DynaPDFChangeJavaScriptAction.shtml), [DynaPDF.ChangeJavaScriptName](https://www.mbsplugins.eu/DynaPDFChangeJavaScriptName.shtml), [DynaPDF.GetActionCount](https://www.mbsplugins.eu/DynaPDFGetActionCount.shtml), [DynaPDF.GetJavaScript](https://www.mbsplugins.eu/DynaPDFGetJavaScript.shtml), [DynaPDF.GetJavaScriptAction](https://www.mbsplugins.eu/DynaPDFGetJavaScriptAction.shtml), [DynaPDF.GetJavaScriptName](https://www.mbsplugins.eu/DynaPDFGetJavaScriptName.shtml).

### Blog Entries

- [New in MBS FileMaker Plugin 13.2](https://www.mbsplugins.de/archive/2023-05-17/New_in_MBS_FileMaker_Plugin_13/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 13.2pr3](https://www.mbsplugins.de/archive/2023-04-20/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 15th April 2023 , last changed 15th April 2023

  
[DynaPDF.AddFontSearchPath](DynaPDFAddFontSearchPath.md) - [DynaPDF.AddOutputIntent](DynaPDFAddOutputIntent.md)

[HTML Version](DynaPDFAddJavaScript.shtml)