-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rb
67 lines (65 loc) · 2.6 KB
/
main.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
require 'prawn'
require 'prawn/measurement_extensions'
require 'active_support/core_ext/string/inflections'
require 'csv'
# Suppress some warning I don't really care about
# I am doing programming!
I18n.enforce_available_locales = false
CSV.foreach('./input.csv', headers: true) do |row|
teacher = row[0]
name = "#{row[1]} #{row[2]}"
division = row[3]
school = row[4]
event = row[5]
eventDate = row[6]
randomName = row[7]
rootfolder = "./output/#{event.parameterize}"
Dir.mkdir("#{rootfolder}") unless File.exists?("#{rootfolder}/")
if randomName != nil
filename = randomName
foldername = "All"
else
filename = name.parameterize
foldername = teacher
end
Dir.mkdir("#{rootfolder}/#{foldername}") unless File.exists?("#{rootfolder}/#{foldername}")
Prawn::Document.generate "#{rootfolder}/#{foldername}/#{filename}.pdf", page_layout: :landscape do
#Uncomment next line to display alignment grid on generated pdf, to aid in element positioning
#stroke_axis
move_down 15
image "./resources/challenge_logo.jpg", position: :center, fit: [800,85]
move_down 40
font "./resources/OpenSans-Italic.ttf"
text "Certificate of Participation", size: 48, align: :center
move_down 20
font "./resources/OpenSans-Regular.ttf"
text "This certificate is presented to", size: 18, align: :center
move_down 15
font "./resources/OpenSans-Bold.ttf"
text name, size: 24, align: :center
move_down 10
font "./resources/OpenSans-Regular.ttf"
text school, size: 18, align: :center
move_down 15
text "in recognition of your exemplary participation in the #{division} Division of the ", size: 18, align: :center
move_down 15
font "./resources/OpenSans-BoldItalic.ttf"
text event, size: 24, align: :center
move_down 15
font "./resources/OpenSans-Regular.ttf"
text "Congratulations on your excellent achievement", size: 18, align: :center
#image "./resources/cee_logo.jpg", at: [0,545], fit: [400,100]
#image "./resources/state_farm_logo.jpg", at: [550,545], fit: [400,100]
image "./resources/njmsig.jpg", at: [0,90], fit: [200,50]
stroke do
stroke_color '666666'
line_width 1
# may need to adjust the value below; move_down does not seem to be working as intended
move_down 80
horizontal_line(5, 200)
end
text_box "Nan J. Morrison\nPresident and Chief Executive Officer\nCouncil for Economic Education", at: [5,50]
# text_box "Chris Caltabiano\nVice President, Domestic Programs\nCouncil for Economic Education", at: [5,75]
text_box "#{eventDate}\nNew York City, NY", at: [600,50]
end
end