Class: MapPrint::PdfHandler

Inherits:
Object
  • Object
show all
Includes:
MapPrint::PdfHandlers::Images, MapPrint::PdfHandlers::Texts
Defined in:
lib/map_print/pdf_handler.rb

Instance Method Summary collapse

Methods included from MapPrint::PdfHandlers::Texts

#print_texts, #text_options

Methods included from MapPrint::PdfHandlers::Images

#image_options, #print_images

Constructor Details

#initialize(context) ⇒ PdfHandler

Returns a new instance of PdfHandler.



9
10
11
# File 'lib/map_print/pdf_handler.rb', line 9

def initialize(context)
  @context = context
end

Instance Method Details



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/map_print/pdf_handler.rb', line 13

def print
  @pdf = Prawn::Document.new @context.pdf_options || {}

  print_map
  print_images(@context.images, @pdf)
  print_texts(@context.texts, @pdf)

  scalebar_image = @context.print_scalebar
  if scalebar_image
    print_image(scalebar_image.path, @context.scalebar[:position])
  end

  legend_image = @context.print_legend
  if legend_image
    print_image(legend_image.path, @context.legend[:position])
  end

  @pdf.render_file(@context.output_path)
end