Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old


Creates a push button.

Component Version macOS Windows Linux Server iOS SDK
DynaPDF 6.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "DynaPDF.CreateButton"; PDF; Name; Caption; Parent; PosX; PosY; Width; Height )   More


Parameter Description Example
PDF The PDF reference returned from DynaPDF.New. $pdf
Name Name of the button. "Test"
Caption The caption to use. "Click me"
Parent Parent group field if any or -1. -1
PosX X-Coordinate of the button. 100
PosY Y-Coordinate of the button. 100
Width Width of the button. 100
Height Height of the button. 20


Returns OK or error.


Creates a push button.
The parameter Name must be a unique name for the button field. It is not allowed to create two buttons with an identical name within the hierarchy in which they appear.
If the coordinate system is bottom-up the point PosX, PosY defines the lower left corner of the button. If the coordinate system is top-down it defines the upper left corner.

Like all form fields, the width and height is measured incl. the line width of the border. The size of normal vector graphics is measured without the line width; this must be taken into account when calculating the width and height of a form field.
The border is drawn by using the current line width and border style (see DynaPDF.SetBorderStyle). However, interactive form fields support natively the line width 1, 2 and 3 units only (thin, medium, thick). Other values can be applied but the appearance can be changed by Adobe's Acrobat when the form is reset by a Reset Form Action.

The appearance can be influenced with the following properties:

The border and background color can be set to NoColor (4294967281), the background or border appears then transparent. The border appears also transparent when the line width was set to zero.
DynaPDF supports also image buttons. To create an image button store the handle of the button in a variable and add one or more images to the different button states (see DynaPDF.AddButtonImage for further information). The caption of the button will be overridden when an image to the up state is added.

Buttons are used to execute an action; the following events are supported by button fields:
  • OnMouseUp
  • OnMouseDown
  • OnMouseExit
  • OnFocus
  • OnBlur

This function is implemented in an ANSI and Unicode compatible version. However, CJK encodings or Unicode are NOT supported by form fields. It is possible to use Unicode strings but the font must NOT use the code page cpUnicode. Unicode strings must contain characters of the actual used 8 bit code page.
Buttons requires a font, if no font was set before Helvetica is used to draw the caption by using the code page 1252. The caption is centred horizontally and vertically. By default the caption is drawn on multiple lines if it does not fit into a single line. To avoid a line break inside a button field remove the flag Multiline (see DynaPDF.SetFieldFlags).
Buttons are excluded from printing by default. If a button should be printable set the flag Print (see DynaPDF.SetFieldFlags() for further information).

Interactive form fields can be structured into several groups by passing a handle of a group field to the parameter Parent. See DynaPDF.CreateGroupField for further information.

If the function succeeds the return value is the field handle, a value greater or equal zero. If the function fails the return value is an error.

See also CreateButton function in DynaPDF manual.

See also

Example Databases

Blog Entries

This function checks for a license.

Created 26th August 2016, last changed 21st July 2023

DynaPDF.CreateAxialShading - DynaPDF.CreateCheckBox