Class: PdfWatermark::WaterMark::Base
- Inherits:
-
Object
- Object
- PdfWatermark::WaterMark::Base
- Includes:
- HexaPDF::Utils::MathHelpers
- Defined in:
- lib/pdf_watermark/water_mark/base.rb
Instance Method Summary collapse
-
#initialize(mark_string, source_path, options) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(mark_string, source_path, options) ⇒ Base
Returns a new instance of Base.
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 |
# File 'lib/pdf_watermark/water_mark/base.rb', line 9 def initialize(mark_string, source_path, ) @source_path = source_path @options = source_size = page_size @content_width = source_size[0] - ([:margin][1] + [:margin][3]) @content_height = source_size[1] - ([:margin][0] + [:margin][2]) @angle = [:angle] == :diagonal ? rad_to_deg(Math.atan(@content_height.to_f/@content_width.to_f)) : [:angle] @mark_string = mark_string @font_size = @options[:font_size] if @font_size.is_a?(String) if @font_size =~ /(\d+[.]?\d*)%/ @font_size = ($1.to_f / 100) * @content_width @font_size = [@font_size, @options[:max_font_size]].min @font_size = [@font_size, @options[:min_font_size]].max else @font_size = @font_size.to_i end end @options[:font] @x = @options[:x] || 0 @y = @options[:y] || @content_height @font = load_font(@options[:font], :watermark_font) end |