Class: Redmine::Export::PDF::ITCPDF
- Inherits:
-
RBPDF
- Object
- RBPDF
- Redmine::Export::PDF::ITCPDF
show all
- Includes:
- I18n
- Defined in:
- lib/redmine/export/pdf.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#fix_text_encoding(txt) ⇒ Object
-
#Footer ⇒ Object
-
#formatted_text(text) ⇒ Object
-
#get_image_filename(attrname) ⇒ Object
-
#get_sever_url(url) ⇒ Object
-
#initialize(lang, orientation = 'P') ⇒ ITCPDF
constructor
A new instance of ITCPDF.
-
#RDMCell(w, h = 0, txt = '', border = 0, ln = 0, align = '', fill = 0, link = '') ⇒ Object
-
#RDMMultiCell(w, h = 0, txt = '', border = 0, align = '', fill = 0, ln = 1) ⇒ Object
-
#RDMwriteFormattedCell(w, h, x, y, txt = '', attachments = [], border = 0, ln = 1, fill = 0) ⇒ Object
-
#RDMwriteHTMLCell(w, h, x, y, txt = '', attachments = [], border = 0, ln = 1, fill = 0) ⇒ Object
-
#SetFont(family, style = '', size = 0, fontfile = '') ⇒ Object
(also: #set_font)
-
#SetFontStyle(style, size) ⇒ Object
Methods included from I18n
#current_language, #day_letter, #day_name, #find_language, #format_date, #format_hours, #format_time, included, #l, #l_hours, #l_hours_short, #l_or_humanize, #languages_options, #ll, #lu, #month_name, #set_language_if_valid, #valid_languages
Constructor Details
#initialize(lang, orientation = 'P') ⇒ ITCPDF
Returns a new instance of ITCPDF.
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/redmine/export/pdf.rb', line 30
def initialize(lang, orientation='P')
set_language_if_valid lang
super(orientation, 'mm', 'A4')
(false)
set_rtl(l(:direction) == 'rtl')
@font_for_content = l(:general_pdf_fontname)
@monospaced_font_for_content = l(:general_pdf_monospaced_fontname)
@font_for_footer = l(:general_pdf_fontname)
set_creator(Redmine::Info.app_name)
set_font(@font_for_content)
([@font_for_content, '', 10])
([@font_for_content, '', 8])
set_default_monospaced_font(@monospaced_font_for_content)
set_display_mode('default', 'OneColumn')
end
|
Instance Attribute Details
Returns the value of attribute footer_date.
28
29
30
|
# File 'lib/redmine/export/pdf.rb', line 28
def
@footer_date
end
|
Instance Method Details
#fix_text_encoding(txt) ⇒ Object
130
131
132
133
134
135
136
137
138
139
140
|
# File 'lib/redmine/export/pdf.rb', line 130
def Footer
set_font(@font_for_footer, 'I', 8)
set_x(15)
if get_rtl
RDMCell(0, 5, @footer_date, 0, 0, 'R')
else
RDMCell(0, 5, @footer_date, 0, 0, 'L')
end
set_x(-30)
RDMCell(0, 5, get_alias_num_page + '/' + get_alias_nb_pages, 0, 0, 'C')
end
|
#formatted_text(text) ⇒ Object
#get_image_filename(attrname) ⇒ Object
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/redmine/export/pdf.rb', line 103
def get_image_filename(attrname)
atta = RDMPdfEncoding.attach(@attachments, attrname, "UTF-8")
if atta
return atta.diskfile
elsif %r{/attachments/download/(?<id>[^/]+)/} =~ attrname and
atta = @attachments.find{|a| a.id.to_s == id} and
atta.readable? and atta.visible?
return atta.diskfile
elsif %r{/attachments/thumbnail/(?<id>[^/]+)/(?<size>\d+)} =~ attrname and
atta = @attachments.find{|a| a.id.to_s == id} and
atta.readable? and atta.visible?
return atta.thumbnail(size: size)
else
return nil
end
end
|
#get_sever_url(url) ⇒ Object
122
123
124
125
126
127
128
|
# File 'lib/redmine/export/pdf.rb', line 122
def get_sever_url(url)
if !empty_string(url) and (url[0, 1] == '/')
Setting.host_name.split('/')[0] + url
else
url
end
end
|
#RDMCell(w, h = 0, txt = '', border = 0, ln = 0, align = '', fill = 0, link = '') ⇒ Object
72
73
74
|
# File 'lib/redmine/export/pdf.rb', line 72
def RDMCell(w, h=0, txt='', border=0, ln=0, align='', fill=0, link='')
cell(w, h, txt, border, ln, align, fill, link)
end
|
#RDMMultiCell(w, h = 0, txt = '', border = 0, align = '', fill = 0, ln = 1) ⇒ Object
76
77
78
|
# File 'lib/redmine/export/pdf.rb', line 76
def RDMMultiCell(w, h=0, txt='', border=0, align='', fill=0, ln=1)
multi_cell(w, h, txt, border, align, fill, ln)
end
|
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/redmine/export/pdf.rb', line 80
def RDMwriteFormattedCell(w, h, x, y, txt='', attachments=[], border=0, ln=1, fill=0)
@attachments = attachments
css_tag = ' <style>
table, td {
border: 2px #ff0000 solid;
}
th { background-color:#EEEEEE; padding: 4px; white-space:nowrap; text-align: center; font-style: bold;}
pre {
background-color: #fafafa;
}
</style>'
txt = txt.gsub(/<p>\{\{((<|<)|(>|>))?toc\}\}<\/p>/i, '')
writeHTMLCell(w, h, x, y, css_tag + txt, border, ln, fill)
end
|
#RDMwriteHTMLCell(w, h, x, y, txt = '', attachments = [], border = 0, ln = 1, fill = 0) ⇒ Object
98
99
100
101
|
# File 'lib/redmine/export/pdf.rb', line 98
def RDMwriteHTMLCell(w, h, x, y, txt='', attachments=[], border=0, ln=1, fill=0)
txt = formatted_text(txt)
RDMwriteFormattedCell(w, h, x, y, txt, attachments, border, ln, fill)
end
|
#SetFont(family, style = '', size = 0, fontfile = '') ⇒ Object
Also known as:
set_font
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/redmine/export/pdf.rb', line 52
def SetFont(family, style='', size=0, fontfile='')
style = +style
style.delete!('B') if family.to_s.casecmp('freeserif') == 0
style.delete!('I') if family.to_s.casecmp('dejavusans') == 0 && current_language.to_s.casecmp("vi") != 0
style.delete!('I') if family.to_s.casecmp('dejavusansmono') == 0
super(family, style, size, fontfile)
end
|
#SetFontStyle(style, size) ⇒ Object
48
49
50
|
# File 'lib/redmine/export/pdf.rb', line 48
def SetFontStyle(style, size)
set_font(@font_for_content, style, size)
end
|