-
-
Save gil27/9442987 to your computer and use it in GitHub Desktop.
Gerar Certificados para a Flexa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: utf-8 | |
require "prawn" | |
class Certificate | |
attr_accessor :path | |
PDF_OPTIONS = { | |
:page_size => "A5", | |
:page_layout => :landscape, | |
:margin => [40, 75] | |
} | |
def initialize(path = nil, name= nil, course = nil, hours = nil, text) | |
@path = path | |
@name = name | |
@course = course | |
@hours = hours | |
@text = text | |
end | |
def pdf | |
Prawn::Document.new(PDF_OPTIONS) do |pdf| | |
pdf.fill_color "40464e" | |
pdf.move_down 60 | |
pdf.text "#{@course}", :size => 40, :style => :bold, :align => :center | |
pdf.move_down 30 | |
pdf.text "#{@name}", :size => 24, :align => :center, :style => :bold | |
pdf.move_down 15 | |
pdf.text "Certificamos que <b>#{@name}</b>, #{@text}", :inline_format => true | |
pdf.move_down 5 | |
pdf.text "Carga horária: #{@hours} horas.", :align => :center | |
pdf.move_down 35 | |
pdf.text "__________________" + " " * 50 + "__________________" | |
pdf.move_up 1 | |
pdf.font "Helvetica" | |
pdf.text_box "Gil Gomes Pereira - Test", :size => 7, :inline_format => true, :at => [10, 77] | |
pdf.text_box "#{@name}", :size => 7, :inline_format => true, :at => [300, 77] | |
end | |
end | |
def save | |
pdf.render_file(path) | |
end | |
end | |
Certificate.new("/tmp/gilgomespereira.pdf", "Gil Gomes Pereira", "TESTE", "10", "concluiu com sucesso o treinamento").save |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment