Class: StampIt::Watermark

Inherits:
Object
  • Object
show all
Defined in:
lib/stamp_it/watermark.rb

Class Method Summary collapse

Class Method Details

.create(file_path, message, config = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/stamp_it/watermark.rb', line 7

def create(file_path, message, config = {})
  begin
    Prawn::Document.generate(file_path) do
      rotate(52, origin: [0,0]) do
        transparent(config[:opacity] || 0.5) do
          fill_color config[:color] || 'FF000'
          draw_text message, size: config[:size] || 16, at: [0, 0]
        end
      end
    end

    return file_path
  rescue
    puts "Something went wrong creating the watermark pdf document."
    return false
  end
end