Method: RBPDF#TextField
- Defined in:
- lib/rbpdf.rb
#TextField(name, w, h, prop = {}, opt = {}, x = '', y = '', js = false) ⇒ Object Also known as: text_field
Creates a text field
- @param string :name
-
field name
- @param float :w
-
Width of the rectangle
- @param float :h
-
Height of the rectangle
- @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 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)
10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 |
# File 'lib/rbpdf.rb', line 10808 def TextField(name, w, h, prop = {}, opt = {}, x = '', y = '', js = false) x = @x if x == '' y = @y if y == '' if js addfield('text', name, x, y, w, h, prop) return end # get default style prop = getFormDefaultProp.merge prop # get annotation data popt = getAnnotOptFromJSProp(prop) # set default appearance stream font = @font_family fontkey = @fontkeys.index font unless @annotation_fonts.include? fontkey @annotation_fonts[font] = fontkey end fontstyle = sprintf("/F%d %.2f Tf %s", fontkey + 1, @font_size_pt, @text_color) popt['da'] = fontstyle popt['ap'] = {} if opt['v'] && !empty_string(opt['v']) # set Appearances popt['ap']['n'] = +"/Tx BMC q #{fontstyle} " gvars = getGraphicVars() @h = h @w = w @t_margin = 0 @c_margin = 0.2 @tmp_buffer = +'' multi_cell(w, h, opt['v'], 0, '', 0, 0, 0.2, 0, true, 0, false, true, 0) popt['ap']['n'] << @tmp_buffer @tmp_buffer = nil popt['ap']['n'] << 'Q EMC' # restore previous values setGraphicVars(gvars, true) else popt['ap']['n'] = "q BT #{fontstyle} ET Q" end # merge options opt = popt.merge opt # remove some conflicting options opt.delete :bs # set remaining annotation data opt['Subtype'] = 'Widget' opt['ft'] = 'Tx' opt['t'] = name # # Additional annotation's parameters (check _putannotsobj() method): # opt['f'] # opt['ap'] # opt['as'] # opt['bs'] # opt['be'] # opt['c'] # opt['border'] # opt['h'] # opt['mk'] # opt['mk']['r'] # opt['mk']['bc'] # opt['mk']['bg'] # opt['mk']['ca'] # opt['mk']['rc'] # opt['mk']['ac'] # opt['mk']['i'] # opt['mk']['ri'] # opt['mk']['ix'] # opt['mk']['if'] # opt['mk']['if']['sw'] # opt['mk']['if']['s'] # opt['mk']['if']['a'] # opt['mk']['if']['fb'] # opt['mk']['tp'] # opt['tu'] # opt['tm'] # opt['ff'] # opt['v'] # opt['dv'] # opt['a'] # opt['aa'] # opt['q'] Annotation(x, y, w, h, name, opt, 0) if @rtl @x -= w else @x += w end end |