Method: RBPDF#CheckBox
- Defined in:
- lib/rbpdf.rb
#CheckBox(name, w, checked = false, prop = {}, opt = {}, onvalue = 'Yes', x = '', y = '', js = false) ⇒ Object Also known as: check_box
Creates a CheckBox field
- @param string :name
-
field name
- @param int :w
-
width
- @param boolean :checked
-
define the initial state.
- @param array :prop
-
javascript field properties. Possible values are described on official Javascript for Acrobat API reference.
- @param array :opt
-
annotation parameters. Possible values are described on official PDF32000_2008 reference.
- @param string :onvalue
-
value to be returned if selected.
- @param float :x
-
Abscissa of the upper-left corner of the rectangle
- @param float :y
-
Ordinate of the upper-left corner of the rectangle
- @param boolean :js
-
if true put the field using JavaScript (requires Acrobat Writer to be rendered).
- @access public
- @author Nicola Asuni
- @since 4.8.000 (2009-09-07)
11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 |
# File 'lib/rbpdf.rb', line 11169 def CheckBox(name, w, checked=false, prop = {}, opt = {}, onvalue = 'Yes', x = '', y = '', js = false) x = @x if x == '' y = @y if y == '' if js addfield('checkbox', name, x, y, w, w, prop) return end prop['value'] ||= ['Yes'] # get default style prop = getFormDefaultProp.merge prop prop['borderStyle'] = 'inset' # get annotation data popt = getAnnotOptFromJSProp(prop) # set additional default options font = 'zapfdingbats' AddFont(font) fontkey = @fontkeys.index font unless @annotation_fonts.include? fontkey @annotation_fonts[font] = fontkey end fontstyle = sprintf('/F%d %.2f Tf', fontkey + 1, @font_size_pt) popt['da'] = "#{fontstyle} #{@text_color}" popt['ap'] = {} popt['ap']['n'] = {} popt['ap']['n']['Yes'] = "q #{@text_color} BT #{fontstyle} 0 0 Td (n) Tj ET Q" popt['ap']['n']['Off'] = "q #{@text_color} BT #{fontstyle} 0 0 Td (o) Tj ET Q" # merge options opt = popt.merge opt # set remaining annotation data opt['Subtype'] = 'Widget' opt['ft'] = 'Btn' opt['t'] = name if empty_string(onvalue) onvalue = 'Yes' end opt['opt'] = [onvalue] if checked opt['v'] = ['/Yes'] opt['as'] = 'Yes' else opt['v'] = ['/Off'] opt['as'] = 'Off' end Annotation(x, y, w, w, name, opt, 0) if @rtl @x -= w else @x += w end end |