class PdfTempura::Render::Debug::Annotation::Base
Public Class Methods
new(field)
click to toggle source
# File lib/pdf_tempura/render/debug/annotation/base.rb, line 7 def initialize(field) @field = field end
Public Instance Methods
render(pdf)
click to toggle source
# File lib/pdf_tempura/render/debug/annotation/base.rb, line 11 def render(pdf) set_field_styling(pdf) render_boxes(pdf) render_text(pdf) end
Private Instance Methods
box_color()
click to toggle source
# File lib/pdf_tempura/render/debug/annotation/base.rb, line 50 def box_color "CCCC33" end
draw_box_border(pdf, color)
click to toggle source
# File lib/pdf_tempura/render/debug/annotation/base.rb, line 54 def draw_box_border(pdf, color) pdf.stroke_color = color pdf.stroke_bounds end
draw_padding(pdf)
click to toggle source
# File lib/pdf_tempura/render/debug/annotation/base.rb, line 64 def draw_padding(pdf) pdf.transparent 0.25 do padding_bounds_box(pdf) do draw_box_border(pdf, "0000CC") end end end
field_options()
click to toggle source
# File lib/pdf_tempura/render/debug/annotation/base.rb, line 72 def field_options raise NotImplementedError, "Implement field_options in your subclass." end
fill_box_color(pdf, color)
click to toggle source
# File lib/pdf_tempura/render/debug/annotation/base.rb, line 59 def fill_box_color(pdf, color) pdf.fill_color = color pdf.fill{ pdf.rectangle [0,pdf.bounds.height], pdf.bounds.width, pdf.bounds.height } end
label_options()
click to toggle source
# File lib/pdf_tempura/render/debug/annotation/base.rb, line 76 def label_options raise NotImplementedError, "Implement label_options in your subclass." end
render_boxes(pdf)
click to toggle source
# File lib/pdf_tempura/render/debug/annotation/base.rb, line 40 def render_boxes(pdf) pdf.transparent 0.5 do field_bounds_box(pdf) do draw_box_border(pdf, box_color) fill_box_color(pdf, box_color) draw_padding(pdf) end end end
render_label(pdf)
click to toggle source
# File lib/pdf_tempura/render/debug/annotation/base.rb, line 36 def render_label(pdf) pdf.text_box "#{@field.name}", label_options end
render_text(pdf)
click to toggle source
# File lib/pdf_tempura/render/debug/annotation/base.rb, line 25 def render_text(pdf) field_bounds_box(pdf) do render_xy(pdf) render_label(pdf) end end
render_xy(pdf)
click to toggle source
# File lib/pdf_tempura/render/debug/annotation/base.rb, line 32 def render_xy(pdf) pdf.text_box "x: #{@field.x} y: #{@field.y} w: #{@field.width} h: #{@field.height}", field_options end
set_field_styling(pdf)
click to toggle source
# File lib/pdf_tempura/render/debug/annotation/base.rb, line 19 def set_field_styling(pdf) pdf.font_size = 7 pdf.fill_color = "000066" pdf.line_width = 0.5 end