Skip to content
This repository has been archived by the owner on Nov 19, 2018. It is now read-only.

Commit

Permalink
Merge pull request #17 from panicinc/master
Browse files Browse the repository at this point in the history
fixes image layout with long metatdata
  • Loading branch information
KrauseFx committed Nov 12, 2014
2 parents 0a411e3 + dd04f9b commit 5581685
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/deliver/pdf_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ class PdfGenerator
def render(deliverer, export_path = nil)
export_path ||= '/tmp'

pdf = Prawn::Document.new(:margin => [0, 0, 0, 0])

resulting_path = "#{export_path}/#{Time.now.to_i}.pdf"
Prawn::Document.generate(resulting_path) do

Expand All @@ -27,13 +25,10 @@ def render(deliverer, export_path = nil)

move_down 30



col1 = 200
modified_color = '0000AA'
standard_color = '000000'


prev_cursor = cursor.to_f
# Description on right side
bounding_box([col1, cursor], width: 340.0) do
Expand All @@ -53,7 +48,6 @@ def render(deliverer, export_path = nil)

move_cursor_to prev_cursor


all_keys = [:support_url, :privacy_url, :software_url, :keywords]

all_keys.each_with_index do |key, index|
Expand Down Expand Up @@ -87,18 +81,27 @@ def render(deliverer, export_path = nil)
end
end

image_width = 60
image_width = bounds.width / 6 # wide enough for 5 portrait screenshots to fit
padding = 10
last_size = nil
top = [cursor, title_bottom].min - padding
index = 0
previous_image_height = 0
move_cursor_to top

if (content[:screenshots] || []).count > 0
content[:screenshots].sort{ |a, b| a.screen_size <=> b.screen_size }.each do |screenshot|

if last_size and last_size != screenshot.screen_size
# Next row (other simulator size)
top -= (previous_image_height + padding)
move_cursor_to top

if top < previous_image_height
start_new_page
top = cursor
end

index = 0
end

Expand Down

0 comments on commit 5581685

Please sign in to comment.