Module: MapPrint::PdfHandlers::Texts

Included in:
MapPrint::PdfHandler
Defined in:
lib/map_print/pdf_handlers/texts.rb

Instance Method Summary collapse

Instance Method Details



4
5
6
7
8
# File 'lib/map_print/pdf_handlers/texts.rb', line 4

def print_texts(texts, pdf)
  (texts || []).each do |text|
    pdf.text_box text[:text], text_options(text)
  end
end

#text_options(text) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/map_print/pdf_handlers/texts.rb', line 10

def text_options(text)
  box = {}

  if text[:position]
    box[:at] = text[:position].values
    box[:at][1] = @pdf.bounds.top - box[:at][1]
  end

  if text[:box_size]
    box[:width] = text[:box_size][:width] if text[:box_size][:width]
    box[:height] = text[:box_size][:height] if text[:box_size][:height]
  end

  text[:options].merge box
end