Skip to content

Instantly share code, notes, and snippets.

@jasonneylon

jasonneylon/form.rb

Last active Dec 10, 2015
Embed
What would you like to do?
Create a form style layout for a PDF using Prawn
require "prawn"
Prawn::Document.generate("form.pdf") do
move_down 5
text "Application form", style: :bold, size: 25
bounding_box([0,cursor], width: bounds.width, height: 120) do
fill_color "DCDCDC"
fill_rectangle [0, cursor], bounds.right, bounds.top
fill_color "000000"
transparent(0.5) { stroke_bounds }
move_down 10
float do
bounding_box([5, cursor], width: 250, height: 200) do
["First name(s):", "Last name:", "Address line 1:", "Address line 2:"].each do |label|
pad(5) { text label }
end
end
end
bounding_box([260, cursor], width: 250, height: 200) do
stroke_color "000000"
fill_color "ffffff"
4.times do
fill_and_stroke_rectangle([5, cursor], 240, 18)
move_down 24
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.