Method: PREP::Core::Label#draw
- Defined in:
- lib/core/label.rb
#draw(prep, region, value, stop_on_drawable = nil) ⇒ Object
指定された領域を元に再計算して描画を実施
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/core/label.rb', line 89 def draw(prep, region, value, stop_on_drawable = nil) if self === stop_on_drawable raise ReRenderJump.new(region) end STDERR.puts("Draw on #{self.class} #{self.identifier}") if ENV['DEBUG'] # 領域判定 calculate_region(prep, region, value) # 文字列指定があるかを確認 if value.nil? || value.to_s == "" string = self.label.dup else string = value.to_s end # 文字列指定に変数がある場合は判定 string.gsub!("[[[current_page_number]]]", prep.current_page_number.to_s) string.gsub!("[[[total_page_count]]]", prep.total_pages.to_s) # 文字列の描画 font = prep.pdf.get_font(self.font, "90ms-RKSJ-H") prep.current_page.begin_text prep.current_page.set_rgb_fill(@color.red.to_f, @color.green.to_f, @color.blue.to_f) region_backup = @region.dup if @expand_region @region = @expand_region.dup @expand_region = nil end left, top = calculate_pos(prep.current_page, region, @region.x, @region.y) right, bottom = left + @region.width, top - @region.height prep.current_page.set_font_and_size(font, @size) prep.current_page.text_rect(left, top, right, bottom, NKF.nkf("--oc=cp932 -W8", string), @align) prep.current_page.end_text @region = region_backup prep.current_page.drawed = true end |