##// END OF EJS Templates
PDF: replace converting error characters instead of returning UTF-8 in FPDF ANSI on Ruby 1.8 (#61)....
Toshi MARUYAMA -
r5231:2f2cdfd96a9c
parent child
Show More
@@ -1,406 +1,412
1 # encoding: utf-8
1 # encoding: utf-8
2 #
2 #
3 # Redmine - project management software
3 # Redmine - project management software
4 # Copyright (C) 2006-2009 Jean-Philippe Lang
4 # Copyright (C) 2006-2009 Jean-Philippe Lang
5 #
5 #
6 # This program is free software; you can redistribute it and/or
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
9 # of the License, or (at your option) any later version.
10 #
10 #
11 # This program is distributed in the hope that it will be useful,
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
14 # GNU General Public License for more details.
15 #
15 #
16 # You should have received a copy of the GNU General Public License
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
19
20 require 'iconv'
20 require 'iconv'
21 require 'rfpdf/fpdf'
21 require 'rfpdf/fpdf'
22 require 'fpdf/chinese'
22 require 'fpdf/chinese'
23 require 'fpdf/japanese'
23 require 'fpdf/japanese'
24 require 'fpdf/korean'
24 require 'fpdf/korean'
25
25
26 module Redmine
26 module Redmine
27 module Export
27 module Export
28 module PDF
28 module PDF
29 include ActionView::Helpers::TextHelper
29 include ActionView::Helpers::TextHelper
30 include ActionView::Helpers::NumberHelper
30 include ActionView::Helpers::NumberHelper
31
31
32 class ITCPDF < TCPDF
32 class ITCPDF < TCPDF
33 include Redmine::I18n
33 include Redmine::I18n
34 attr_accessor :footer_date
34 attr_accessor :footer_date
35
35
36 def initialize(lang)
36 def initialize(lang)
37 super()
37 super()
38 set_language_if_valid lang
38 set_language_if_valid lang
39 @font_for_content = 'FreeSans'
39 @font_for_content = 'FreeSans'
40 @font_for_footer = 'FreeSans'
40 @font_for_footer = 'FreeSans'
41 SetCreator(Redmine::Info.app_name)
41 SetCreator(Redmine::Info.app_name)
42 SetFont(@font_for_content)
42 SetFont(@font_for_content)
43 end
43 end
44
44
45 def SetFontStyle(style, size)
45 def SetFontStyle(style, size)
46 SetFont(@font_for_content, style, size)
46 SetFont(@font_for_content, style, size)
47 end
47 end
48
48
49 def SetTitle(txt)
49 def SetTitle(txt)
50 txt = begin
50 txt = begin
51 utf16txt = Iconv.conv('UTF-16BE', 'UTF-8', txt)
51 utf16txt = Iconv.conv('UTF-16BE', 'UTF-8', txt)
52 hextxt = "<FEFF" # FEFF is BOM
52 hextxt = "<FEFF" # FEFF is BOM
53 hextxt << utf16txt.unpack("C*").map {|x| sprintf("%02X",x) }.join
53 hextxt << utf16txt.unpack("C*").map {|x| sprintf("%02X",x) }.join
54 hextxt << ">"
54 hextxt << ">"
55 rescue
55 rescue
56 txt
56 txt
57 end || ''
57 end || ''
58 super(txt)
58 super(txt)
59 end
59 end
60
60
61 def textstring(s)
61 def textstring(s)
62 # Format a text string
62 # Format a text string
63 if s =~ /^</ # This means the string is hex-dumped.
63 if s =~ /^</ # This means the string is hex-dumped.
64 return s
64 return s
65 else
65 else
66 return '('+escape(s)+')'
66 return '('+escape(s)+')'
67 end
67 end
68 end
68 end
69
69
70 alias RDMCell Cell
70 alias RDMCell Cell
71 alias RDMMultiCell MultiCell
71 alias RDMMultiCell MultiCell
72
72
73 def Footer
73 def Footer
74 SetFont(@font_for_footer, 'I', 8)
74 SetFont(@font_for_footer, 'I', 8)
75 SetY(-15)
75 SetY(-15)
76 SetX(15)
76 SetX(15)
77 RDMCell(0, 5, @footer_date, 0, 0, 'L')
77 RDMCell(0, 5, @footer_date, 0, 0, 'L')
78 SetY(-15)
78 SetY(-15)
79 SetX(-30)
79 SetX(-30)
80 RDMCell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
80 RDMCell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
81 end
81 end
82 end
82 end
83
83
84 class IFPDF < FPDF
84 class IFPDF < FPDF
85 include Redmine::I18n
85 include Redmine::I18n
86 attr_accessor :footer_date
86 attr_accessor :footer_date
87
87
88 def initialize(lang)
88 def initialize(lang)
89 super()
89 super()
90 set_language_if_valid lang
90 set_language_if_valid lang
91 case current_language.to_s.downcase
91 case current_language.to_s.downcase
92 when 'ko'
92 when 'ko'
93 extend(PDF_Korean)
93 extend(PDF_Korean)
94 AddUHCFont()
94 AddUHCFont()
95 @font_for_content = 'UHC'
95 @font_for_content = 'UHC'
96 @font_for_footer = 'UHC'
96 @font_for_footer = 'UHC'
97 when 'ja'
97 when 'ja'
98 extend(PDF_Japanese)
98 extend(PDF_Japanese)
99 AddSJISFont()
99 AddSJISFont()
100 @font_for_content = 'SJIS'
100 @font_for_content = 'SJIS'
101 @font_for_footer = 'SJIS'
101 @font_for_footer = 'SJIS'
102 when 'zh'
102 when 'zh'
103 extend(PDF_Chinese)
103 extend(PDF_Chinese)
104 AddGBFont()
104 AddGBFont()
105 @font_for_content = 'GB'
105 @font_for_content = 'GB'
106 @font_for_footer = 'GB'
106 @font_for_footer = 'GB'
107 when 'zh-tw'
107 when 'zh-tw'
108 extend(PDF_Chinese)
108 extend(PDF_Chinese)
109 AddBig5Font()
109 AddBig5Font()
110 @font_for_content = 'Big5'
110 @font_for_content = 'Big5'
111 @font_for_footer = 'Big5'
111 @font_for_footer = 'Big5'
112 else
112 else
113 @font_for_content = 'Arial'
113 @font_for_content = 'Arial'
114 @font_for_footer = 'Helvetica'
114 @font_for_footer = 'Helvetica'
115 end
115 end
116 SetCreator(Redmine::Info.app_name)
116 SetCreator(Redmine::Info.app_name)
117 SetFont(@font_for_content)
117 SetFont(@font_for_content)
118 end
118 end
119
119
120 def SetFontStyle(style, size)
120 def SetFontStyle(style, size)
121 SetFont(@font_for_content, style, size)
121 SetFont(@font_for_content, style, size)
122 end
122 end
123
123
124 def SetTitle(txt)
124 def SetTitle(txt)
125 txt = begin
125 txt = begin
126 utf16txt = Iconv.conv('UTF-16BE', 'UTF-8', txt)
126 utf16txt = Iconv.conv('UTF-16BE', 'UTF-8', txt)
127 hextxt = "<FEFF" # FEFF is BOM
127 hextxt = "<FEFF" # FEFF is BOM
128 hextxt << utf16txt.unpack("C*").map {|x| sprintf("%02X",x) }.join
128 hextxt << utf16txt.unpack("C*").map {|x| sprintf("%02X",x) }.join
129 hextxt << ">"
129 hextxt << ">"
130 rescue
130 rescue
131 txt
131 txt
132 end || ''
132 end || ''
133 super(txt)
133 super(txt)
134 end
134 end
135
135
136 def textstring(s)
136 def textstring(s)
137 # Format a text string
137 # Format a text string
138 if s =~ /^</ # This means the string is hex-dumped.
138 if s =~ /^</ # This means the string is hex-dumped.
139 return s
139 return s
140 else
140 else
141 return '('+escape(s)+')'
141 return '('+escape(s)+')'
142 end
142 end
143 end
143 end
144
144
145 def fix_text_encoding(txt)
145 def fix_text_encoding(txt)
146 txt ||= ''
146 txt ||= ''
147 if txt.respond_to?(:force_encoding)
147 if txt.respond_to?(:force_encoding)
148 txt.force_encoding('UTF-8')
148 txt.force_encoding('UTF-8')
149 txt = txt.encode(l(:general_pdf_encoding), :invalid => :replace,
149 txt = txt.encode(l(:general_pdf_encoding), :invalid => :replace,
150 :undef => :replace, :replace => '?')
150 :undef => :replace, :replace => '?')
151 txt.force_encoding('ASCII-8BIT')
151 txt.force_encoding('ASCII-8BIT')
152 else
152 else
153 @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')
153 @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')
154 txt = begin
154 txtar = ""
155 @ic.iconv(txt)
155 begin
156 txtar += @ic.iconv(txt)
157 rescue Iconv::IllegalSequence
158 txtar += $!.success
159 txt = '?' + $!.failed[1,$!.failed.length]
160 retry
156 rescue
161 rescue
157 txt
162 txtar += $!.success
158 end
163 end
164 txt = txtar
159 end
165 end
160 # 0x5c char handling
166 # 0x5c char handling
161 txt.gsub(/\\/, "\\\\\\\\")
167 txt.gsub(/\\/, "\\\\\\\\")
162 end
168 end
163
169
164 def RDMCell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
170 def RDMCell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
165 Cell(w,h,fix_text_encoding(txt),border,ln,align,fill,link)
171 Cell(w,h,fix_text_encoding(txt),border,ln,align,fill,link)
166 end
172 end
167
173
168 def RDMMultiCell(w,h=0,txt='',border=0,align='',fill=0)
174 def RDMMultiCell(w,h=0,txt='',border=0,align='',fill=0)
169 MultiCell(w,h,fix_text_encoding(txt),border,align,fill)
175 MultiCell(w,h,fix_text_encoding(txt),border,align,fill)
170 end
176 end
171
177
172 def Footer
178 def Footer
173 SetFont(@font_for_footer, 'I', 8)
179 SetFont(@font_for_footer, 'I', 8)
174 SetY(-15)
180 SetY(-15)
175 SetX(15)
181 SetX(15)
176 RDMCell(0, 5, @footer_date, 0, 0, 'L')
182 RDMCell(0, 5, @footer_date, 0, 0, 'L')
177 SetY(-15)
183 SetY(-15)
178 SetX(-30)
184 SetX(-30)
179 RDMCell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
185 RDMCell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
180 end
186 end
181 alias alias_nb_pages AliasNbPages
187 alias alias_nb_pages AliasNbPages
182 end
188 end
183
189
184 # Returns a PDF string of a list of issues
190 # Returns a PDF string of a list of issues
185 def issues_to_pdf(issues, project, query)
191 def issues_to_pdf(issues, project, query)
186 if ( current_language.to_s.downcase == 'ko' ||
192 if ( current_language.to_s.downcase == 'ko' ||
187 current_language.to_s.downcase == 'ja' ||
193 current_language.to_s.downcase == 'ja' ||
188 current_language.to_s.downcase == 'zh' ||
194 current_language.to_s.downcase == 'zh' ||
189 current_language.to_s.downcase == 'zh-tw' ||
195 current_language.to_s.downcase == 'zh-tw' ||
190 current_language.to_s.downcase == 'th' )
196 current_language.to_s.downcase == 'th' )
191 pdf = IFPDF.new(current_language)
197 pdf = IFPDF.new(current_language)
192 else
198 else
193 pdf = ITCPDF.new(current_language)
199 pdf = ITCPDF.new(current_language)
194 end
200 end
195 title = query.new_record? ? l(:label_issue_plural) : query.name
201 title = query.new_record? ? l(:label_issue_plural) : query.name
196 title = "#{project} - #{title}" if project
202 title = "#{project} - #{title}" if project
197 pdf.SetTitle(title)
203 pdf.SetTitle(title)
198 pdf.alias_nb_pages
204 pdf.alias_nb_pages
199 pdf.footer_date = format_date(Date.today)
205 pdf.footer_date = format_date(Date.today)
200 pdf.AddPage("L")
206 pdf.AddPage("L")
201
207
202 row_height = 6
208 row_height = 6
203 col_width = []
209 col_width = []
204 unless query.columns.empty?
210 unless query.columns.empty?
205 col_width = query.columns.collect {|column| column.name == :subject ? 4.0 : 1.0 }
211 col_width = query.columns.collect {|column| column.name == :subject ? 4.0 : 1.0 }
206 ratio = 262.0 / col_width.inject(0) {|s,w| s += w}
212 ratio = 262.0 / col_width.inject(0) {|s,w| s += w}
207 col_width = col_width.collect {|w| w * ratio}
213 col_width = col_width.collect {|w| w * ratio}
208 end
214 end
209
215
210 # title
216 # title
211 pdf.SetFontStyle('B',11)
217 pdf.SetFontStyle('B',11)
212 pdf.RDMCell(190,10, title)
218 pdf.RDMCell(190,10, title)
213 pdf.Ln
219 pdf.Ln
214
220
215 # headers
221 # headers
216 pdf.SetFontStyle('B',8)
222 pdf.SetFontStyle('B',8)
217 pdf.SetFillColor(230, 230, 230)
223 pdf.SetFillColor(230, 230, 230)
218 pdf.RDMCell(15, row_height, "#", 1, 0, 'L', 1)
224 pdf.RDMCell(15, row_height, "#", 1, 0, 'L', 1)
219 query.columns.each_with_index do |column, i|
225 query.columns.each_with_index do |column, i|
220 pdf.RDMCell(col_width[i], row_height, column.caption, 1, 0, 'L', 1)
226 pdf.RDMCell(col_width[i], row_height, column.caption, 1, 0, 'L', 1)
221 end
227 end
222 pdf.Ln
228 pdf.Ln
223
229
224 # rows
230 # rows
225 pdf.SetFontStyle('',8)
231 pdf.SetFontStyle('',8)
226 pdf.SetFillColor(255, 255, 255)
232 pdf.SetFillColor(255, 255, 255)
227 previous_group = false
233 previous_group = false
228 issues.each do |issue|
234 issues.each do |issue|
229 if query.grouped? &&
235 if query.grouped? &&
230 (group = query.group_by_column.value(issue)) != previous_group
236 (group = query.group_by_column.value(issue)) != previous_group
231 pdf.SetFontStyle('B',9)
237 pdf.SetFontStyle('B',9)
232 pdf.RDMCell(277, row_height,
238 pdf.RDMCell(277, row_height,
233 (group.blank? ? 'None' : group.to_s) + " (#{query.issue_count_by_group[group]})",
239 (group.blank? ? 'None' : group.to_s) + " (#{query.issue_count_by_group[group]})",
234 1, 1, 'L')
240 1, 1, 'L')
235 pdf.SetFontStyle('',8)
241 pdf.SetFontStyle('',8)
236 previous_group = group
242 previous_group = group
237 end
243 end
238 pdf.RDMCell(15, row_height, issue.id.to_s, 1, 0, 'L', 1)
244 pdf.RDMCell(15, row_height, issue.id.to_s, 1, 0, 'L', 1)
239 query.columns.each_with_index do |column, i|
245 query.columns.each_with_index do |column, i|
240 s = if column.is_a?(QueryCustomFieldColumn)
246 s = if column.is_a?(QueryCustomFieldColumn)
241 cv = issue.custom_values.detect {|v| v.custom_field_id == column.custom_field.id}
247 cv = issue.custom_values.detect {|v| v.custom_field_id == column.custom_field.id}
242 show_value(cv)
248 show_value(cv)
243 else
249 else
244 value = issue.send(column.name)
250 value = issue.send(column.name)
245 if value.is_a?(Date)
251 if value.is_a?(Date)
246 format_date(value)
252 format_date(value)
247 elsif value.is_a?(Time)
253 elsif value.is_a?(Time)
248 format_time(value)
254 format_time(value)
249 else
255 else
250 value
256 value
251 end
257 end
252 end
258 end
253 pdf.RDMCell(col_width[i], row_height, s.to_s, 1, 0, 'L', 1)
259 pdf.RDMCell(col_width[i], row_height, s.to_s, 1, 0, 'L', 1)
254 end
260 end
255 pdf.Ln
261 pdf.Ln
256 end
262 end
257 if issues.size == Setting.issues_export_limit.to_i
263 if issues.size == Setting.issues_export_limit.to_i
258 pdf.SetFontStyle('B',10)
264 pdf.SetFontStyle('B',10)
259 pdf.RDMCell(0, row_height, '...')
265 pdf.RDMCell(0, row_height, '...')
260 end
266 end
261 pdf.Output
267 pdf.Output
262 end
268 end
263
269
264 # Returns a PDF string of a single issue
270 # Returns a PDF string of a single issue
265 def issue_to_pdf(issue)
271 def issue_to_pdf(issue)
266 if ( current_language.to_s.downcase == 'ko' ||
272 if ( current_language.to_s.downcase == 'ko' ||
267 current_language.to_s.downcase == 'ja' ||
273 current_language.to_s.downcase == 'ja' ||
268 current_language.to_s.downcase == 'zh' ||
274 current_language.to_s.downcase == 'zh' ||
269 current_language.to_s.downcase == 'zh-tw' ||
275 current_language.to_s.downcase == 'zh-tw' ||
270 current_language.to_s.downcase == 'th' )
276 current_language.to_s.downcase == 'th' )
271 pdf = IFPDF.new(current_language)
277 pdf = IFPDF.new(current_language)
272 else
278 else
273 pdf = ITCPDF.new(current_language)
279 pdf = ITCPDF.new(current_language)
274 end
280 end
275 pdf.SetTitle("#{issue.project} - ##{issue.tracker} #{issue.id}")
281 pdf.SetTitle("#{issue.project} - ##{issue.tracker} #{issue.id}")
276 pdf.alias_nb_pages
282 pdf.alias_nb_pages
277 pdf.footer_date = format_date(Date.today)
283 pdf.footer_date = format_date(Date.today)
278 pdf.AddPage
284 pdf.AddPage
279
285
280 pdf.SetFontStyle('B',11)
286 pdf.SetFontStyle('B',11)
281 pdf.RDMCell(190,10,
287 pdf.RDMCell(190,10,
282 "#{issue.project} - #{issue.tracker} # #{issue.id}: #{issue.subject}")
288 "#{issue.project} - #{issue.tracker} # #{issue.id}: #{issue.subject}")
283 pdf.Ln
289 pdf.Ln
284
290
285 y0 = pdf.GetY
291 y0 = pdf.GetY
286
292
287 pdf.SetFontStyle('B',9)
293 pdf.SetFontStyle('B',9)
288 pdf.RDMCell(35,5, l(:field_status) + ":","LT")
294 pdf.RDMCell(35,5, l(:field_status) + ":","LT")
289 pdf.SetFontStyle('',9)
295 pdf.SetFontStyle('',9)
290 pdf.RDMCell(60,5, issue.status.to_s,"RT")
296 pdf.RDMCell(60,5, issue.status.to_s,"RT")
291 pdf.SetFontStyle('B',9)
297 pdf.SetFontStyle('B',9)
292 pdf.RDMCell(35,5, l(:field_priority) + ":","LT")
298 pdf.RDMCell(35,5, l(:field_priority) + ":","LT")
293 pdf.SetFontStyle('',9)
299 pdf.SetFontStyle('',9)
294 pdf.RDMCell(60,5, issue.priority.to_s,"RT")
300 pdf.RDMCell(60,5, issue.priority.to_s,"RT")
295 pdf.Ln
301 pdf.Ln
296
302
297 pdf.SetFontStyle('B',9)
303 pdf.SetFontStyle('B',9)
298 pdf.RDMCell(35,5, l(:field_author) + ":","L")
304 pdf.RDMCell(35,5, l(:field_author) + ":","L")
299 pdf.SetFontStyle('',9)
305 pdf.SetFontStyle('',9)
300 pdf.RDMCell(60,5, issue.author.to_s,"R")
306 pdf.RDMCell(60,5, issue.author.to_s,"R")
301 pdf.SetFontStyle('B',9)
307 pdf.SetFontStyle('B',9)
302 pdf.RDMCell(35,5, l(:field_category) + ":","L")
308 pdf.RDMCell(35,5, l(:field_category) + ":","L")
303 pdf.SetFontStyle('',9)
309 pdf.SetFontStyle('',9)
304 pdf.RDMCell(60,5, issue.category.to_s,"R")
310 pdf.RDMCell(60,5, issue.category.to_s,"R")
305 pdf.Ln
311 pdf.Ln
306
312
307 pdf.SetFontStyle('B',9)
313 pdf.SetFontStyle('B',9)
308 pdf.RDMCell(35,5, l(:field_created_on) + ":","L")
314 pdf.RDMCell(35,5, l(:field_created_on) + ":","L")
309 pdf.SetFontStyle('',9)
315 pdf.SetFontStyle('',9)
310 pdf.RDMCell(60,5, format_date(issue.created_on),"R")
316 pdf.RDMCell(60,5, format_date(issue.created_on),"R")
311 pdf.SetFontStyle('B',9)
317 pdf.SetFontStyle('B',9)
312 pdf.RDMCell(35,5, l(:field_assigned_to) + ":","L")
318 pdf.RDMCell(35,5, l(:field_assigned_to) + ":","L")
313 pdf.SetFontStyle('',9)
319 pdf.SetFontStyle('',9)
314 pdf.RDMCell(60,5, issue.assigned_to.to_s,"R")
320 pdf.RDMCell(60,5, issue.assigned_to.to_s,"R")
315 pdf.Ln
321 pdf.Ln
316
322
317 pdf.SetFontStyle('B',9)
323 pdf.SetFontStyle('B',9)
318 pdf.RDMCell(35,5, l(:field_updated_on) + ":","LB")
324 pdf.RDMCell(35,5, l(:field_updated_on) + ":","LB")
319 pdf.SetFontStyle('',9)
325 pdf.SetFontStyle('',9)
320 pdf.RDMCell(60,5, format_date(issue.updated_on),"RB")
326 pdf.RDMCell(60,5, format_date(issue.updated_on),"RB")
321 pdf.SetFontStyle('B',9)
327 pdf.SetFontStyle('B',9)
322 pdf.RDMCell(35,5, l(:field_due_date) + ":","LB")
328 pdf.RDMCell(35,5, l(:field_due_date) + ":","LB")
323 pdf.SetFontStyle('',9)
329 pdf.SetFontStyle('',9)
324 pdf.RDMCell(60,5, format_date(issue.due_date),"RB")
330 pdf.RDMCell(60,5, format_date(issue.due_date),"RB")
325 pdf.Ln
331 pdf.Ln
326
332
327 for custom_value in issue.custom_field_values
333 for custom_value in issue.custom_field_values
328 pdf.SetFontStyle('B',9)
334 pdf.SetFontStyle('B',9)
329 pdf.RDMCell(35,5, custom_value.custom_field.name + ":","L")
335 pdf.RDMCell(35,5, custom_value.custom_field.name + ":","L")
330 pdf.SetFontStyle('',9)
336 pdf.SetFontStyle('',9)
331 pdf.RDMMultiCell(155,5, (show_value custom_value),"R")
337 pdf.RDMMultiCell(155,5, (show_value custom_value),"R")
332 end
338 end
333
339
334 pdf.SetFontStyle('B',9)
340 pdf.SetFontStyle('B',9)
335 pdf.RDMCell(35,5, l(:field_subject) + ":","LTB")
341 pdf.RDMCell(35,5, l(:field_subject) + ":","LTB")
336 pdf.SetFontStyle('',9)
342 pdf.SetFontStyle('',9)
337 pdf.RDMCell(155,5, issue.subject,"RTB")
343 pdf.RDMCell(155,5, issue.subject,"RTB")
338 pdf.Ln
344 pdf.Ln
339
345
340 pdf.SetFontStyle('B',9)
346 pdf.SetFontStyle('B',9)
341 pdf.RDMCell(35,5, l(:field_description) + ":")
347 pdf.RDMCell(35,5, l(:field_description) + ":")
342 pdf.SetFontStyle('',9)
348 pdf.SetFontStyle('',9)
343 pdf.RDMMultiCell(155,5, issue.description.to_s,"BR")
349 pdf.RDMMultiCell(155,5, issue.description.to_s,"BR")
344
350
345 pdf.Line(pdf.GetX, y0, pdf.GetX, pdf.GetY)
351 pdf.Line(pdf.GetX, y0, pdf.GetX, pdf.GetY)
346 pdf.Line(pdf.GetX, pdf.GetY, 170, pdf.GetY)
352 pdf.Line(pdf.GetX, pdf.GetY, 170, pdf.GetY)
347 pdf.Ln
353 pdf.Ln
348
354
349 if issue.changesets.any? &&
355 if issue.changesets.any? &&
350 User.current.allowed_to?(:view_changesets, issue.project)
356 User.current.allowed_to?(:view_changesets, issue.project)
351 pdf.SetFontStyle('B',9)
357 pdf.SetFontStyle('B',9)
352 pdf.RDMCell(190,5, l(:label_associated_revisions), "B")
358 pdf.RDMCell(190,5, l(:label_associated_revisions), "B")
353 pdf.Ln
359 pdf.Ln
354 for changeset in issue.changesets
360 for changeset in issue.changesets
355 pdf.SetFontStyle('B',8)
361 pdf.SetFontStyle('B',8)
356 pdf.RDMCell(190,5,
362 pdf.RDMCell(190,5,
357 format_time(changeset.committed_on) + " - " + changeset.author.to_s)
363 format_time(changeset.committed_on) + " - " + changeset.author.to_s)
358 pdf.Ln
364 pdf.Ln
359 unless changeset.comments.blank?
365 unless changeset.comments.blank?
360 pdf.SetFontStyle('',8)
366 pdf.SetFontStyle('',8)
361 pdf.RDMMultiCell(190,5, changeset.comments.to_s)
367 pdf.RDMMultiCell(190,5, changeset.comments.to_s)
362 end
368 end
363 pdf.Ln
369 pdf.Ln
364 end
370 end
365 end
371 end
366
372
367 pdf.SetFontStyle('B',9)
373 pdf.SetFontStyle('B',9)
368 pdf.RDMCell(190,5, l(:label_history), "B")
374 pdf.RDMCell(190,5, l(:label_history), "B")
369 pdf.Ln
375 pdf.Ln
370 for journal in issue.journals.find(
376 for journal in issue.journals.find(
371 :all, :include => [:user, :details],
377 :all, :include => [:user, :details],
372 :order => "#{Journal.table_name}.created_on ASC")
378 :order => "#{Journal.table_name}.created_on ASC")
373 pdf.SetFontStyle('B',8)
379 pdf.SetFontStyle('B',8)
374 pdf.RDMCell(190,5,
380 pdf.RDMCell(190,5,
375 format_time(journal.created_on) + " - " + journal.user.name)
381 format_time(journal.created_on) + " - " + journal.user.name)
376 pdf.Ln
382 pdf.Ln
377 pdf.SetFontStyle('I',8)
383 pdf.SetFontStyle('I',8)
378 for detail in journal.details
384 for detail in journal.details
379 pdf.RDMCell(190,5, "- " + show_detail(detail, true))
385 pdf.RDMCell(190,5, "- " + show_detail(detail, true))
380 pdf.Ln
386 pdf.Ln
381 end
387 end
382 if journal.notes?
388 if journal.notes?
383 pdf.SetFontStyle('',8)
389 pdf.SetFontStyle('',8)
384 pdf.RDMMultiCell(190,5, journal.notes.to_s)
390 pdf.RDMMultiCell(190,5, journal.notes.to_s)
385 end
391 end
386 pdf.Ln
392 pdf.Ln
387 end
393 end
388
394
389 if issue.attachments.any?
395 if issue.attachments.any?
390 pdf.SetFontStyle('B',9)
396 pdf.SetFontStyle('B',9)
391 pdf.RDMCell(190,5, l(:label_attachment_plural), "B")
397 pdf.RDMCell(190,5, l(:label_attachment_plural), "B")
392 pdf.Ln
398 pdf.Ln
393 for attachment in issue.attachments
399 for attachment in issue.attachments
394 pdf.SetFontStyle('',8)
400 pdf.SetFontStyle('',8)
395 pdf.RDMCell(80,5, attachment.filename)
401 pdf.RDMCell(80,5, attachment.filename)
396 pdf.RDMCell(20,5, number_to_human_size(attachment.filesize),0,0,"R")
402 pdf.RDMCell(20,5, number_to_human_size(attachment.filesize),0,0,"R")
397 pdf.RDMCell(25,5, format_date(attachment.created_on),0,0,"R")
403 pdf.RDMCell(25,5, format_date(attachment.created_on),0,0,"R")
398 pdf.RDMCell(65,5, attachment.author.name,0,0,"R")
404 pdf.RDMCell(65,5, attachment.author.name,0,0,"R")
399 pdf.Ln
405 pdf.Ln
400 end
406 end
401 end
407 end
402 pdf.Output
408 pdf.Output
403 end
409 end
404 end
410 end
405 end
411 end
406 end
412 end
General Comments 0
You need to be logged in to leave comments. Login now