Module: Aptible::DocumentHelpers::Watermark
- Included in:
- Aptible::DocumentHelpers
- Defined in:
- lib/aptible/document_helpers/watermark.rb
Instance Method Summary collapse
- #create_confidential_stamp(rotation, main_y_pos, sub_y_pos, format) ⇒ Object
- #define_watermarks(format = :portrait) ⇒ Object
-
#watermarked(stamp_type = 'CONFIDENTIAL', format = :portrait, &block) ⇒ Object
rubocop:disable MethodLength.
Instance Method Details
#create_confidential_stamp(rotation, main_y_pos, sub_y_pos, format) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/aptible/document_helpers/watermark.rb', line 40 def create_confidential_stamp(rotation, main_y_pos, sub_y_pos, format) create_stamp("CONFIDENTIAL - #{format}") do rotate(rotation, origin: [0, 0]) do fill_color 'f3f3f3' font('Proxima Nova', style: :bold, size: 100) do draw_text 'CONFIDENTIAL', at: [40, main_y_pos] end font('Proxima Nova', style: :normal, size: 70) do draw_text 'Do Not Distribute', at: [130, sub_y_pos] end end end end |
#define_watermarks(format = :portrait) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/aptible/document_helpers/watermark.rb', line 25 def define_watermarks(format = :portrait) @defined_formats ||= [] # Catch strings format = format.to_sym return if @defined_formats.include?(format) case format when :portrait create_confidential_stamp(48, 0, -60, format) when :landscape create_confidential_stamp(15, 130, 70, format) end @defined_formats << format end |
#watermarked(stamp_type = 'CONFIDENTIAL', format = :portrait, &block) ⇒ Object
rubocop:disable MethodLength
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/aptible/document_helpers/watermark.rb', line 5 def watermarked(stamp_type = 'CONFIDENTIAL', format = :portrait, &block) # Tying the definition to the current format helps ensure # the watermark is created with the right margin boxes define_watermarks(format) stamp_name = "#{stamp_type} - #{format}" # Watermark the current page stamp stamp_name # Watermark additional pages on_page_create do stamp stamp_name @landscape_pages.push(page_number) if format == :landscape end yield if block_given? # clears the callback on_page_create end |