Icon
The Icon object represents an icon stored at the document level in a PDF file. Icons can be used with button form fields to display custom images. Icons are accessed through the Doc.icons property or created using Doc.addIcon.
Example
// Get an existing icon from the document
var icon = this.getIcon("MyIcon")
// Apply the icon to a button field
var button = this.getField("MyButton")
button.buttonSetIcon(icon)
Properties
name
| Secure | Type | Access |
|---|---|---|
| No | string | R |
The name of the icon as stored in the PDF document.
Example
// List all icon names in the document
if (this.icons != null) {
this.icons.forEach(icon => {
console.println("Icon name: " + icon.name)
})
}
Methods
Icon objects in Revu do not expose any public methods. Icons are managed through the Doc object methods such as addIcon, getIcon, importIcon, and removeIcon.
Usage notes
Icons are typically used in conjunction with button form fields to display custom graphics. The workflow generally involves:
-
Importing an icon into the document using Doc.importIcon()
-
Retrieving the icon using Doc.getIcon() or accessing it through Doc.icons
-
Applying the icon to a button field using Field.buttonSetIcon()
Example
// Complete workflow for using icons
// 1. Import an icon (user will be prompted to select an image file)
var result = this.importIcon("CompanyLogo")
if (result == 0) {
// 2. Get the icon reference
var logoIcon = this.getIcon("CompanyLogo")
// 3. Apply to a button field
var logoButton = this.getField("LogoButton")
if (logoButton) {
logoButton.buttonSetIcon(logoIcon)
}
}
Resources
Revu 21
Revu JavaScript
JavaScript
