Class: Sibyl::Form
- Inherits:
-
Object
- Object
- Sibyl::Form
- Defined in:
- lib/sibyl/form.rb
Class Method Summary collapse
Class Method Details
.convert_to_pdf(folder, pdf) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/sibyl/form.rb', line 29 def self.convert_to_pdf(folder, pdf) im = Magick::ImageList.new(pdf) { self.density = '300' self.background_color = "none" } im.reverse.each_with_index do |img, i| filename = sprintf "page%03d.png", i out = folder.join(filename) STDERR.puts "writing: #{out}" xr = img.write(out) p xr end end |
.create_form(task, form, file) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sibyl/form.rb', line 16 def self.create_form(task,form,file) dir = Rails.root.join("app", "sibyl", task, form) pdf_file = dir.to_s.gsub(/$/, '.pdf') STDERR.puts "Dir: #{dir}" STDERR.puts "Saving: #{pdf_file}" STDERR.puts "Creating: #{dir}" FileUtils.mkdir_p dir File.open(pdf_file, 'wb') do |f| f.write(file.read) end STDERR.puts "Done" convert_to_pdf(dir,pdf_file) end |
.usage ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/sibyl/form.rb', line 6 def self.usage STDERR.puts <<EOT Usage: bin/rails generate siblform <task name> <form name> <pdffile> Task name and form name must be valid file names. Task name is a general category for all forms that relate to a particular task. This is just for organization purposes. Both task and form name should be alphanumeric and not contain any whitespace. EOT exit end |