Skip to content

Instantly share code, notes, and snippets.

@arvindvyas
Created April 1, 2020 13:10
Show Gist options
  • Save arvindvyas/0b2c4d6623aeb634fc130c0e3975d0e0 to your computer and use it in GitHub Desktop.
Save arvindvyas/0b2c4d6623aeb634fc130c0e3975d0e0 to your computer and use it in GitHub Desktop.
img_paths = ["/Users/workspace/ARVIND/2.jpeg", "/Users/workspace/ARVIND/2.jpeg", "/Users/workspace/ARVIND/REDCAPTIN/2.jpeg"]
Prawn::Document.generate("/Users/workspace/ARVIND/red_captain/my-file.pdf") do |pdf|
img_paths.each do |img_path|
# PDF regions involve bounding boxes.
# The default bounding box is simply the page itself.
# The :fit option tells Prawn to scale the image to the current
# bounding box (in other words, the current page)
pdf.image img_path, :fit => [pdf.bounds.right, pdf.bounds.top]
# Insert a page break, unless this is the last page
pdf.start_new_page unless pdf.page_count == img_paths.length
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment