Skip to content

Instantly share code, notes, and snippets.

@andrerpbts
Created October 19, 2012 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andrerpbts/3920007 to your computer and use it in GitHub Desktop.
Save andrerpbts/3920007 to your computer and use it in GitHub Desktop.
Prawn
@pdf = Prawn::Document.new(:margin => 0, :skip_page_creation => true)
images.each do |imagem|
geo = Paperclip::Geometry.from_file(imagem)
if geo.height >= geo.width
size = [612, 792]
@pdf.start_new_page(:page_size => "A4", :layout => :portrait)
else
size = [792, 612]
@pdf.start_new_page(:page_size => "A4", :layout => :landscape)
end
@pdf.image imagem, :fit => size
end
render :text => @pdf.render, :content_type => "application/pdf; charset=ISO-8859-1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment