Prawn image position

Posted by John on Stack Overflow See other posts from Stack Overflow or by John
Published on 2010-05-10T14:48:16Z Indexed on 2010/05/15 2:24 UTC
Read the original article Hit count: 198

Filed under:
|

I'm trying to layout 6 images per page with prawn in Ruby:

case (idx % 6) # ugly                                                                                                                                                                                 
  when 0 : (pdf.start_new_page; pdf.image img, :position => :left, :vposition => :top, :width => 270)
  when 1 : pdf.image img, :position => :right, :vposition => :top, :width => 270
  when 2 : pdf.image img, :position => :left, :vposition => :center, :width => 270
  when 3 : pdf.image img, :position => :right, :vposition => :center, :width => 270
  when 4 : pdf.image img, :position => :left, :vposition => :bottom, :width => 270
  when 5 : pdf.image img, :position => :right, :vposition => :bottom, :width => 270
end

Not sure what I'm doing wrong, but it prints the first 3 images to the PDF, then creates a new page and prints the last three:

Page 1:

<img>     <img> 
<blank> <blank>
<blank> <blank>

Page 2:

<blank> <blank>
<blank>   <img>
<img>     <img>

Any suggestions would help.

© Stack Overflow or respective owner

Related posts about prawn

Related posts about ruby