Method: RBPDF#Annotation
- Defined in:
- lib/rbpdf.rb
#Annotation(x, y, w, h, text, opt = {'Subtype'=>'Text'}, spaces = 0) ⇒ Object Also known as: annotation
Puts a markup annotation on a rectangular area of the page.
-
!!!!THE ANNOTATION SUPPORT IS NOT YET FULLY IMPLEMENTED !!!!
- @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 float :w
-
Width of the rectangle
- @param float :h
-
Height of the rectangle
- @param mixed :text
-
annotation text or alternate content
- @param array :opt
-
array of options (see section 8.4 of PDF reference 1.7).
- @param int :spaces
-
number of spaces on the text to link
- @access public
- @since 4.0.018 (2008-08-06)
3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 |
# File 'lib/rbpdf.rb', line 3051 def Annotation(x, y, w, h, text, opt={'Subtype'=>'Text'}, spaces=0) x = @x if x == '' y = @y if y == '' # recalculate coordinates to account for graphic transformations if !@transfmatrix.nil? @transfmatrix_key.downto(1) do |i| maxid = @transfmatrix[i].length - 1 maxid.downto(0) do |j| ctm = @transfmatrix[i][j] if !ctm['a'].nil? x = x * @k y = (@h - y) * @k w = w * @k h = h * @k # top left xt = x yt = y x1 = (ctm['a'] * xt) + (ctm['c'] * yt) + ctm['e'] y1 = (ctm['b'] * xt) + (ctm['d'] * yt) + ctm['f'] # top right xt = x + w yt = y x2 = (ctm['a'] * xt) + (ctm['c'] * yt) + ctm['e'] y2 = (ctm['b'] * xt) + (ctm['d'] * yt) + ctm['f'] # bottom left xt = x yt = y - h x3 = (ctm['a'] * xt) + (ctm['c'] * yt) + ctm['e'] y3 = (ctm['b'] * xt) + (ctm['d'] * yt) + ctm['f'] # bottom right xt = x + w yt = y - h x4 = (ctm['a'] * xt) + (ctm['c'] * yt) + ctm['e'] y4 = (ctm['b'] * xt) + (ctm['d'] * yt) + ctm['f'] # new coordinates (rectangle area) x = [x1, x2, x3, x4].min y = [y1, y2, y3, y4].max w = ([x1, x2, x3, x4].max - x) / @k h = (y - [y1, y2, y3, y4].min) / @k x = x / @k y = @h - (y / @k) end end end end if @page <= 0 page = 1 else page = @page end @page_annots[page] ||= [] @page_annots[page].push 'x' => x, 'y' => y, 'w' => w, 'h' => h, 'txt' => text, 'opt' => opt, 'numspaces' => spaces if ((opt['Subtype'] == 'FileAttachment') or (opt['Subtype'] == 'Sound')) and !empty_string(opt['FS']) and File.exist?(opt['FS']) and [File.basename(opt['FS'])].nil? [File.basename(opt['FS'])] = {'file' => opt['FS'], 'n' => (.length + )} end # Add widgets annotation's icons if opt['mk'] and opt['mk']['i'] and File.exist?(opt['mk']['i']) Image(opt['mk']['i'], '', '', 10, 10, '', '', '', false, 300, '', false, false, 0, false, true) end if opt['mk'] and opt['mk']['ri'] and File.exist?(opt['mk']['ri']) Image(opt['mk']['ri'], '', '', 0, 0, '', '', '', false, 300, '', false, false, 0, false, true) end if opt['mk'] and opt['mk']['ix'] and File.exist?(opt['mk']['ix']) Image(opt['mk']['ix'], '', '', 0, 0, '', '', '', false, 300, '', false, false, 0, false, true) end @annot_obj_id += 1 end |