DynaPDF.AddButtonImage
----------------------

Add/Set a form field button image.

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

MBS( "DynaPDF.AddButtonImage"; PDF; Field; Button State; Caption; Image File Path ) 

**MBS**( **"DynaPDF.AddButtonImage";** /\* Add/Set a form field button image. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$Field**; /\* The field index or field name.e.g. "FirstName" \*/   
**$Button State**; /\* The state of the button.  
Can be "Up", "Down" or "RollOver".e.g. "Up" \*/   
**$Caption**; /\* The caption text.e.g. "Hello" \*/   
**$Image File Path**) /\* The native file path for the image file.e.g. "C:\\test\\picture.png" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |
| Field | The field index or field name. | "FirstName" |
| Button State | The state of the button.   Can be "Up", "Down" or "RollOver". | "Up" |
| Caption | The caption text. | "Hello" |
| Image File Path | The native file path for the image file. | "C:\\test\\picture.png" |

### Result

Returns OK or error.

### Description

Add/Set a form field button image.  
Adds an image to a push button to one or more of the three different states of a button. The parameter Field must be handle of a button field that was returned by a [DynaPDF.CreateButton](DynaPDFCreateButton.md) function call or the index of an existing field of type button.   
The parameter State defines the button state in which the image should appear. Each state is optional; it is possible to add different images to all three states of the button. The rollover state should get a different image than the other states. If two states should get the same image, the image is physically inserted only once to the PDF file.   
DynaPDF checks whether duplicate images are already available before inserting an image again. Depending on the parameter UseTransparency (see [DynaPDF.SetUseTransparency](DynaPDFSetUseTransparency.md)) the image appears with a transparent background or opaque (default transparent). However, note that the background of the button must be transparent too to get a transparent button. Otherwise the button is still opaque due the opaque background of the button.   
The parameter Caption is optional, it can be empty. Each state can contain its own caption which is drawn horizontally and vertically centered by default. The alignment can be changed with the function SetFieldTextAlign(). Because each button state is directly drawn when calling the function, the alignment must be set before this function is called.   
If a button has already an image for a specific button state, the existing image will be replaced with the new one.   
See also [AddButtonImage](https://www.monkeybreadsoftware.com/DynaPDF-Manual/AddButtonImage.shtml) function in DynaPDF manual.

### See also

- [DynaPDF.AddButtonImageEx2](DynaPDFAddButtonImageEx2.md)
- [DynaPDF.CreateButton](DynaPDFCreateButton.md)
- [DynaPDF.New](DynaPDFNew.md)
- [DynaPDF.SetUseTransparency](DynaPDFSetUseTransparency.md)

### Release notes

- **Version 11.5**
    - Added [DynaPDF.AddButtonImageEx2](https://www.mbsplugins.eu/DynaPDFAddButtonImageEx2.shtml) function.
- **Version 10.2**
    - Added [DynaPDF.AddButtonImage](https://www.mbsplugins.eu/DynaPDFAddButtonImage.shtml) function.

### Blog Entries

- [News about the MBS FileMaker Plugin 10.2](https://www.mbsplugins.de/archive/2020-05-19/News_about_the_MBS_FileMaker_P/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 10.2pr4](https://www.mbsplugins.de/archive/2020-04-20/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 17th April 2020 , last changed 7th November 2021

  
[DynaPDF.AddBookmarkEx](DynaPDFAddBookmarkEx.md) - [DynaPDF.AddButtonImageEx2](DynaPDFAddButtonImageEx2.md)

[HTML Version](DynaPDFAddButtonImage.shtml)