diff --git a/lib/squib/graphics/save_doc.rb b/lib/squib/graphics/save_doc.rb index 5a08f79..bf3cf65 100644 --- a/lib/squib/graphics/save_doc.rb +++ b/lib/squib/graphics/save_doc.rb @@ -14,14 +14,15 @@ module Squib # @return [nil] # @api public def save_pdf(opts = {}) - p = needs(opts, [:file_to_save, :creatable_dir, :margin, :gap, :trim]) - width = 11 * @dpi ; height = 8.5 * @dpi #TODO: allow this to be specified too + p = needs(opts, [:range, :file_to_save, :creatable_dir, :margin, :gap, :trim]) + width = 11 * @dpi + height = 8.5 * @dpi #TODO: allow this to be specified too cc = Cairo::Context.new(Cairo::PDFSurface.new("#{p[:dir]}/#{p[:file]}", width, height)) - x = p[:margin] ; y = p[:margin] - + x = p[:margin] + y = p[:margin] @progress_bar.start("Saving PDF to #{p[:dir]}/#{p[:file]}", p[:range].size) do |bar| - @cards.each_with_index do |card, i| - surface = trim(card.cairo_surface, p[:trim], @width, @height) + p[:range].each do |i| + surface = trim(@cards[i].cairo_surface, p[:trim], @width, @height) cc.set_source(surface, x, y) cc.paint bar.increment @@ -30,12 +31,13 @@ module Squib x = p[:margin] y += surface.height + p[:gap] if y > (height - surface.height - p[:margin]) - x = p[:margin] ; y = p[:margin] + x = p[:margin] + y = p[:margin] cc.show_page #next page end end end - end + end end # :nodoc: diff --git a/lib/squib/graphics/shapes.rb b/lib/squib/graphics/shapes.rb index 4ebe902..a7fd083 100644 --- a/lib/squib/graphics/shapes.rb +++ b/lib/squib/graphics/shapes.rb @@ -4,7 +4,8 @@ module Squib # :nodoc: # @api private def rect(x, y, width, height, x_radius, y_radius, fill_color, stroke_color, stroke_width) - width=@width if width==:native; height=@height if height==:native + width = @width if width == :native + height = @height if height == :native use_cairo do |cc| cc.rounded_rectangle(x, y, width, height, x_radius, y_radius) cc.set_source_color(stroke_color)