Class: Redmine::Export::PDF::ITCPDF

Inherits:
TCPDF
  • Object
show all
Includes:
I18n
Defined in:
lib/redmine/export/pdf.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from I18n

#current_language, #day_name, #find_language, #format_date, #format_time, included, #l, #l_hours, #l_or_humanize, #ll, #month_name, #set_language_if_valid, #valid_languages

Constructor Details

#initialize(lang) ⇒ ITCPDF



31
32
33
34
35
36
37
38
# File 'lib/redmine/export/pdf.rb', line 31

def initialize(lang)
  super()
  set_language_if_valid lang
  @font_for_content = 'FreeSans'
  @font_for_footer  = 'FreeSans'
  SetCreator(Redmine::Info.app_name)
  SetFont(@font_for_content)
end

Instance Attribute Details

Returns the value of attribute footer_date



29
30
31
# File 'lib/redmine/export/pdf.rb', line 29

def footer_date
  @footer_date
end

Instance Method Details



68
69
70
71
72
73
74
75
76
# File 'lib/redmine/export/pdf.rb', line 68

def Footer
  SetFont(@font_for_footer, 'I', 8)
  SetY(-15)
  SetX(15)
  RDMCell(0, 5, @footer_date, 0, 0, 'L')
  SetY(-15)
  SetX(-30)
  RDMCell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
end

#SetFontStyle(style, size) ⇒ Object



40
41
42
# File 'lib/redmine/export/pdf.rb', line 40

def SetFontStyle(style, size)
  SetFont(@font_for_content, style, size)
end

#SetTitle(txt) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/redmine/export/pdf.rb', line 44

def SetTitle(txt)
  txt = begin
    utf16txt = Iconv.conv('UTF-16BE', 'UTF-8', txt)
    hextxt = "<FEFF"  # FEFF is BOM
    hextxt << utf16txt.unpack("C*").map {|x| sprintf("%02X",x) }.join
    hextxt << ">"
  rescue
    txt
  end || ''
  super(txt)
end

#textstring(s) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/redmine/export/pdf.rb', line 56

def textstring(s)
  # Format a text string
  if s =~ /^</  # This means the string is hex-dumped.
    return s
  else
    return '('+escape(s)+')'
  end
end