Module: Palapala::Helper

Defined in:
lib/palapala/helper.rb

Class Method Summary collapse

Class Method Details



13
14
15
# File 'lib/palapala/helper.rb', line 13

def self.footer(left: "", center: "", right: "", margin: "1cm")
  self.header(left:, center:, right:, margin:)
end

.header(left: "", center: "", right: "", margin: "1cm") ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/palapala/helper.rb', line 3

def self.header(left: "", center: "", right: "", margin: "1cm")
  <<~HTML
    <div style="display: flex; justify-content: space-between; width: 100%; margin-left: #{margin}; margin-right: #{margin};">
      <div style="text-align: left; flex: 1;">#{left}</div>
      <div style="text-align: center; flex: 1;">#{center}</div>
      <div style="text-align: right; flex: 1;">#{right}</div>
  </div>
  HTML
end

.hf_template(from:) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/palapala/helper.rb', line 40

def self.hf_template(from:)
  return if from.nil?
  style = <<~HTML.freeze
    <style>
      #header, #footer {
        font-size: 10pt;
        display: flex;
        justify-content: center;
      }
    </style>
  HTML
  style + from
end

.page_numberObject



17
18
19
20
21
# File 'lib/palapala/helper.rb', line 17

def self.page_number
  <<~HTML
    <span class="pageNumber"></span>/<span class="totalPages"></span>
  HTML
end

.watermark(watermark, angle: "-15deg", color: "rgba(25,25,25,0.25)", font_size: "72pt") ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/palapala/helper.rb', line 23

def self.watermark(watermark, angle: "-15deg", color: "rgba(25,25,25,0.25)", font_size: "72pt")
  <<~HTML
    <style>
      .palapala_pdf_watermark {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) rotate(#{angle});
        font-size: #{font_size};
        color: #{color};
        z-index: 9999;
      }
    </style>
    <span class="palapala_pdf_watermark">#{watermark}</span>
  HTML
end