PROGRAMMING GUIDE
HOOPS Publish has functions to populate fields on a page. These fields must have been created with Adobe Acrobat and the Forms tool. As an example, visit the pdf_samples directory in the HOOPS Publish package and open any PDF file using Acrobat. Then edit the file with the Forms tool and the Edit menu. There, you’ll have a view on all the fields contained in the PDF file. Using Acrobat Forms, you can design the PDF page to contain different type of fields. HOOPS Publish functions supports text fields or buttons fields. All functions have the same kind of prototype: It always has the field name as an argument to identify the field, as well as an argument to set a value to the field.
Acrobat Forms enables customers to define text fields. With text fields you can predefine a large set of options for the text appearance or the behavior. These options will be respected by the population function. Options are for example the font, the text or background color, the alignment in the field, or a multiline capability. To populate a text field, use the function A3DPDFPageFieldTextSetValue. The text value is specified as a UTF-8 string and characters are only restricted to the characters supported by the font selected for the field. The text can have multiple lines, in this case the carriage return character should be ’\r’.
Customers can design a PDF page to receive an image. For this, you need to design a button and set the layout option to contain an icon (’icon only’ for example). The image can be stored at the template creation and never change, or can be programmatically filled with the HOOPS Publish function A3DPDFPageFieldButtonSetIcon. With this function, the value argument is an A3DPDFImage object which has to be created with the function A3DPDFImageCreate.
The visibility for a field can be programmatically specified. This enables customers to design a PDF template with a large list of fields and to adapt the list of visible fields at runtime depending on the context.
Customers can design fields to invoke JavaScript when the field is triggered by the end user. To store Javascript so that it is invoked when the user triggers a widget, see the following code snippet:
Note: JavaScript variables or functions can be defined at a document level. To store JavaScript at a document level, use the function A3DPDFDocumentAddJavaScriptFromString.
The action event is different depending on the type of the field.
dropdown list (combo box): the JavaScript is launched when the end user selects an item in the list. For dropdown lists, the JavaScript should be as follows. Note that only the item value can be retrieved from the JavaScript, the export value is not enabled here.
list boxes: the JavaScript is launched when the end user selects an item in the list. For list boxes, the JavaScript should be as follows. Note that only item value can be retrieved from the JavaScript, the export value is not enables here.
For documentation on the JavaScript supported by Acrobat, please consult Adobe documentation.