Skip to content

Commit

Permalink
Read the title from the legend file.
Browse files Browse the repository at this point in the history
  • Loading branch information
gravitystorm committed Aug 21, 2014
1 parent 40848fb commit 6eb4914
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/mapnik_legendary.rb
Expand Up @@ -81,6 +81,7 @@ def self.generate_legend(legend_file, map_file, options)
f.write(docs.to_html)
f.close

docs.to_pdf(File.join(Dir.pwd, 'output', 'legend.pdf'))
title = legend.key?('title') ? legend['title'] : 'Legend'
docs.to_pdf(File.join(Dir.pwd, 'output', 'legend.pdf'), title)
end
end
5 changes: 3 additions & 2 deletions lib/mapnik_legendary/docwriter.rb
Expand Up @@ -22,7 +22,7 @@ def to_html
doc
end

def to_pdf(filename)
def to_pdf(filename, title)
entries = @entries
Prawn::Document.generate(filename, page_size: 'A4') do
font_families.update(
Expand All @@ -32,7 +32,8 @@ def to_pdf(filename)
)
font 'Ubuntu'
font_size 12
text 'Legend', style: :bold, size: 24, align: :center
text title, style: :bold, size: 24, align: :center
move_down(40)
data = Array.new
entries.each do |entry|
data << { image: File.join(File.dirname(filename), entry[0]),
Expand Down

0 comments on commit 6eb4914

Please sign in to comment.