##// END OF EJS Templates
PDF: import CJK patches and all languages use TCPDF (#8312)....
Toshi MARUYAMA -
r5600:29f6dd2a9e77
parent child
Show More
@@ -210,11 +210,7 module Redmine
210 210
211 211 # Returns a PDF string of a list of issues
212 212 def issues_to_pdf(issues, project, query)
213 if l(:general_pdf_encoding).upcase != 'UTF-8'
214 pdf = IFPDF.new(current_language)
215 else
216 pdf = ITCPDF.new(current_language)
217 end
213 pdf = ITCPDF.new(current_language)
218 214 title = query.new_record? ? l(:label_issue_plural) : query.name
219 215 title = "#{project} - #{title}" if project
220 216 pdf.SetTitle(title)
@@ -358,11 +354,7 module Redmine
358 354
359 355 # Returns a PDF string of a single issue
360 356 def issue_to_pdf(issue)
361 if l(:general_pdf_encoding).upcase != 'UTF-8'
362 pdf = IFPDF.new(current_language)
363 else
364 pdf = ITCPDF.new(current_language)
365 end
357 pdf = ITCPDF.new(current_language)
366 358 pdf.SetTitle("#{issue.project} - ##{issue.tracker} #{issue.id}")
367 359 pdf.alias_nb_pages
368 360 pdf.footer_date = format_date(Date.today)
@@ -507,11 +507,7 module Redmine
507 507 end if Object.const_defined?(:Magick)
508 508
509 509 def to_pdf
510 if l(:general_pdf_encoding).upcase != 'UTF-8'
511 pdf = ::Redmine::Export::PDF::IFPDF.new(current_language)
512 else
513 pdf = ::Redmine::Export::PDF::ITCPDF.new(current_language)
514 end
510 pdf = ::Redmine::Export::PDF::ITCPDF.new(current_language)
515 511 pdf.SetTitle("#{l(:label_gantt)} #{project}")
516 512 pdf.alias_nb_pages
517 513 pdf.footer_date = format_date(Date.today)
@@ -116,7 +116,7 module PDF_Chinese
116 116 end
117 117
118 118 def GetStringWidth(s)
119 if(@CurrentFont['type']=='Type0')
119 if(@current_font['type']=='Type0')
120 120 return GetMBStringWidth(s)
121 121 else
122 122 return super(s)
@@ -126,7 +126,7 module PDF_Chinese
126 126 def GetMBStringWidth(s)
127 127 #Multi-byte version of GetStringWidth()
128 128 l=0
129 cw=@CurrentFont['cw']
129 cw=@current_font['cw']
130 130 nb=s.length
131 131 i=0
132 132 while(i<nb)
@@ -139,11 +139,11 module PDF_Chinese
139 139 i+=2
140 140 end
141 141 end
142 return l*@FontSize/1000
142 return l*@font_size/1000
143 143 end
144 144
145 145 def MultiCell(w,h,txt,border=0,align='L',fill=0)
146 if(@CurrentFont['type']=='Type0')
146 if(@current_font['type']=='Type0')
147 147 MBMultiCell(w,h,txt,border,align,fill)
148 148 else
149 149 super(w,h,txt,border,align,fill)
@@ -152,11 +152,11 module PDF_Chinese
152 152
153 153 def MBMultiCell(w,h,txt,border=0,align='L',fill=0)
154 154 #Multi-byte version of MultiCell()
155 cw=@CurrentFont['cw']
155 cw=@current_font['cw']
156 156 if(w==0)
157 w=@w-@rMargin-@x
157 w=@w-@r_margin-@x
158 158 end
159 wmax=(w-2*@cMargin)*1000/@FontSize
159 wmax=(w-2*@c_margin)*1000/@font_size
160 160 s=txt.gsub("\r",'')
161 161 nb=s.length
162 162 if(nb>0 and s[nb-1]=="\n")
@@ -233,11 +233,11 module PDF_Chinese
233 233 b+='B'
234 234 end
235 235 Cell(w,h,s[j,i-j],b,2,align,fill)
236 @x=@lMargin
236 @x=@l_margin
237 237 end
238 238
239 239 def Write(h,txt,link='')
240 if(@CurrentFont['type']=='Type0')
240 if(@current_font['type']=='Type0')
241 241 MBWrite(h,txt,link)
242 242 else
243 243 super(h,txt,link)
@@ -246,9 +246,9 module PDF_Chinese
246 246
247 247 def MBWrite(h,txt,link)
248 248 #Multi-byte version of Write()
249 cw=@CurrentFont['cw']
250 w=@w-@rMargin-@x
251 wmax=(w-2*@cMargin)*1000/@FontSize
249 cw=@current_font['cw']
250 w=@w-@r_margin-@x
251 wmax=(w-2*@c_margin)*1000/@font_size
252 252 s=txt.gsub("\r",'')
253 253 nb=s.length
254 254 sep=-1
@@ -269,9 +269,9 module PDF_Chinese
269 269 j=i
270 270 l=0
271 271 if(nl==1)
272 @x=@lMargin
273 w=@w-@rMargin-@x
274 wmax=(w-2*@cMargin)*1000/@FontSize
272 @x=@l_margin
273 w=@w-@r_margin-@x
274 wmax=(w-2*@c_margin)*1000/@font_size
275 275 end
276 276 nl+=1
277 277 next
@@ -283,12 +283,12 module PDF_Chinese
283 283 if(l>wmax)
284 284 #Automatic line break
285 285 if(sep==-1 or i==j)
286 if(@x>@lMargin)
286 if(@x>@l_margin)
287 287 #Move to next line
288 @x=@lMargin
288 @x=@l_margin
289 289 @y+=h
290 w=@w-@rMargin-@x
291 wmax=(w-2*@cMargin)*1000/@FontSize
290 w=@w-@r_margin-@x
291 wmax=(w-2*@c_margin)*1000/@font_size
292 292 i+=1
293 293 nl+=1
294 294 next
@@ -305,9 +305,9 module PDF_Chinese
305 305 j=i
306 306 l=0
307 307 if(nl==1)
308 @x=@lMargin
309 w=@w-@rMargin-@x
310 wmax=(w-2*@cMargin)*1000/@FontSize
308 @x=@l_margin
309 w=@w-@r_margin-@x
310 wmax=(w-2*@c_margin)*1000/@font_size
311 311 end
312 312 nl+=1
313 313 else
@@ -316,7 +316,7 module PDF_Chinese
316 316 end
317 317 #Last chunk
318 318 if(i!=j)
319 Cell(l/1000*@FontSize,h,s[j,i-j],0,0,'',0,link)
319 Cell(l/1000*@font_size,h,s[j,i-j],0,0,'',0,link)
320 320 end
321 321 end
322 322
@@ -332,10 +332,10 private
332 332 end
333 333 # mqr=get_magic_quotes_runtime()
334 334 # set_magic_quotes_runtime(0)
335 @FontFiles.each_pair do |file, info|
335 @font_files.each_pair do |file, info|
336 336 #Font file embedding
337 337 newobj()
338 @FontFiles[file]['n']=@n
338 @font_files[file]['n']=@n
339 339 if(defined('FPDF_FONTPATH'))
340 340 file=FPDF_FONTPATH+file
341 341 end
@@ -411,7 +411,7 private
411 411 end
412 412 file=font['file']
413 413 if(file)
414 s+=' /FontFile'+(font['type']=='Type1' ? '' : '2')+' '+@FontFiles[file]['n']+' 0 R'
414 s+=' /FontFile'+(font['type']=='Type1' ? '' : '2')+' '+@font_files[file]['n']+' 0 R'
415 415 end
416 416 out(s+'>>')
417 417 out('endobj')
@@ -86,7 +86,7 module PDF_Japanese
86 86 end
87 87
88 88 def GetStringWidth(s)
89 if(@CurrentFont['type']=='Type0')
89 if(@current_font['type']=='Type0')
90 90 return GetSJISStringWidth(s)
91 91 else
92 92 return super(s)
@@ -96,7 +96,7 module PDF_Japanese
96 96 def GetSJISStringWidth(s)
97 97 #SJIS version of GetStringWidth()
98 98 l=0
99 cw=@CurrentFont['cw']
99 cw=@current_font['cw']
100 100 nb=s.length
101 101 i=0
102 102 while(i<nb)
@@ -115,11 +115,11 module PDF_Japanese
115 115 i+=2
116 116 end
117 117 end
118 return l*@FontSize/1000
118 return l*@font_size/1000
119 119 end
120 120
121 121 def MultiCell(w,h,txt,border=0,align='L',fill=0)
122 if(@CurrentFont['type']=='Type0')
122 if(@current_font['type']=='Type0')
123 123 SJISMultiCell(w,h,txt,border,align,fill)
124 124 else
125 125 super(w,h,txt,border,align,fill)
@@ -128,11 +128,11 module PDF_Japanese
128 128
129 129 def SJISMultiCell(w,h,txt,border=0,align='L',fill=0)
130 130 #Output text with automatic or explicit line breaks
131 cw=@CurrentFont['cw']
131 cw=@current_font['cw']
132 132 if(w==0)
133 w=@w-@rMargin-@x
133 w=@w-@r_margin-@x
134 134 end
135 wmax=(w-2*@cMargin)*1000/@FontSize
135 wmax=(w-2*@c_margin)*1000/@font_size
136 136 s=txt.gsub("\r",'')
137 137 nb=s.length
138 138 if(nb>0 and s[nb-1]=="\n")
@@ -221,11 +221,11 module PDF_Japanese
221 221 b+='B'
222 222 end
223 223 Cell(w,h,s[j,i-j],b,2,align,fill)
224 @x=@lMargin
224 @x=@l_margin
225 225 end
226 226
227 227 def Write(h,txt,link='')
228 if(@CurrentFont['type']=='Type0')
228 if(@current_font['type']=='Type0')
229 229 SJISWrite(h,txt,link)
230 230 else
231 231 super(h,txt,link)
@@ -234,9 +234,9 module PDF_Japanese
234 234
235 235 def SJISWrite(h,txt,link)
236 236 #SJIS version of Write()
237 cw=@CurrentFont['cw']
238 w=@w-@rMargin-@x
239 wmax=(w-2*@cMargin)*1000/@FontSize
237 cw=@current_font['cw']
238 w=@w-@r_margin-@x
239 wmax=(w-2*@c_margin)*1000/@font_size
240 240 s=txt.gsub("\r",'')
241 241 nb=s.length
242 242 sep=-1
@@ -257,9 +257,9 module PDF_Japanese
257 257 l=0
258 258 if(nl==1)
259 259 #Go to left margin
260 @x=@lMargin
261 w=@w-@rMargin-@x
262 wmax=(w-2*@cMargin)*1000/@FontSize
260 @x=@l_margin
261 w=@w-@r_margin-@x
262 wmax=(w-2*@c_margin)*1000/@font_size
263 263 end
264 264 nl+=1
265 265 next
@@ -285,12 +285,12 module PDF_Japanese
285 285 if(l>wmax)
286 286 #Automatic line break
287 287 if(sep==-1 or i==j)
288 if(@x>@lMargin)
288 if(@x>@l_margin)
289 289 #Move to next line
290 @x=@lMargin
290 @x=@l_margin
291 291 @y+=h
292 w=@w-@rMargin-@x
293 wmax=(w-2*@cMargin)*1000/@FontSize
292 w=@w-@r_margin-@x
293 wmax=(w-2*@c_margin)*1000/@font_size
294 294 i+=n
295 295 nl+=1
296 296 next
@@ -307,9 +307,9 module PDF_Japanese
307 307 j=i
308 308 l=0
309 309 if(nl==1)
310 @x=@lMargin
311 w=@w-@rMargin-@x
312 wmax=(w-2*@cMargin)*1000/@FontSize
310 @x=@l_margin
311 w=@w-@r_margin-@x
312 wmax=(w-2*@c_margin)*1000/@font_size
313 313 end
314 314 nl+=1
315 315 else
@@ -321,7 +321,7 module PDF_Japanese
321 321 end
322 322 #Last chunk
323 323 if(i!=j)
324 Cell(l/1000*@FontSize,h,s[j,i-j],0,0,'',0,link)
324 Cell(l/1000*@font_size,h,s[j,i-j],0,0,'',0,link)
325 325 end
326 326 end
327 327
@@ -337,10 +337,10 private
337 337 end
338 338 # mqr=get_magic_quotes_runtime()
339 339 # set_magic_quotes_runtime(0)
340 @FontFiles.each_pair do |file, info|
340 @font_files.each_pair do |file, info|
341 341 #Font file embedding
342 342 newobj()
343 @FontFiles[file]['n']=@n
343 @font_files[file]['n']=@n
344 344 if(defined('FPDF_FONTPATH'))
345 345 file=FPDF_FONTPATH+file
346 346 end
@@ -414,7 +414,7 private
414 414 end
415 415 file=font['file']
416 416 if(file)
417 s+=' /FontFile'+(font['type']=='Type1' ? '' : '2')+' '+@FontFiles[file]['n']+' 0 R'
417 s+=' /FontFile'+(font['type']=='Type1' ? '' : '2')+' '+@font_files[file]['n']+' 0 R'
418 418 end
419 419 out(s+'>>')
420 420 out('endobj')
@@ -85,7 +85,7 UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
85 85 end
86 86
87 87 def GetStringWidth(s)
88 if(@CurrentFont['type']=='Type0')
88 if(@current_font['type']=='Type0')
89 89 return GetMBStringWidth(s)
90 90 else
91 91 return super(s)
@@ -95,7 +95,7 UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
95 95 def GetMBStringWidth(s)
96 96 #Multi-byte version of GetStringWidth()
97 97 l=0
98 cw=@CurrentFont['cw']
98 cw=@current_font['cw']
99 99 nb=s.length
100 100 i=0
101 101 while(i<nb)
@@ -108,11 +108,11 UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
108 108 i+=2
109 109 end
110 110 end
111 return l*@FontSize/1000
111 return l*@font_size/1000
112 112 end
113 113
114 114 def MultiCell(w,h,txt,border=0,align='L',fill=0)
115 if(@CurrentFont['type']=='Type0')
115 if(@current_font['type']=='Type0')
116 116 MBMultiCell(w,h,txt,border,align,fill)
117 117 else
118 118 super(w,h,txt,border,align,fill)
@@ -121,11 +121,11 UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
121 121
122 122 def MBMultiCell(w,h,txt,border=0,align='L',fill=0)
123 123 #Multi-byte version of MultiCell()
124 cw=@CurrentFont['cw']
124 cw=@current_font['cw']
125 125 if(w==0)
126 w=@w-@rMargin-@x
126 w=@w-@r_margin-@x
127 127 end
128 wmax=(w-2*@cMargin)*1000/@FontSize
128 wmax=(w-2*@c_margin)*1000/@font_size
129 129 s=txt.gsub("\r",'')
130 130 nb=s.length
131 131 if(nb>0 and s[nb-1]=="\n")
@@ -202,11 +202,11 UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
202 202 b+='B'
203 203 end
204 204 Cell(w,h,s[j,i-j],b,2,align,fill)
205 @x=@lMargin
205 @x=@l_margin
206 206 end
207 207
208 208 def Write(h,txt,link='')
209 if(@CurrentFont['type']=='Type0')
209 if(@current_font['type']=='Type0')
210 210 MBWrite(h,txt,link)
211 211 else
212 212 super(h,txt,link)
@@ -215,9 +215,9 UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
215 215
216 216 def MBWrite(h,txt,link)
217 217 #Multi-byte version of Write()
218 cw=@CurrentFont['cw']
219 w=@w-@rMargin-@x
220 wmax=(w-2*@cMargin)*1000/@FontSize
218 cw=@current_font['cw']
219 w=@w-@r_margin-@x
220 wmax=(w-2*@c_margin)*1000/@font_size
221 221 s=txt.gsub("\r",'')
222 222 nb=s.length
223 223 sep=-1
@@ -238,9 +238,9 UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
238 238 j=i
239 239 l=0
240 240 if(nl==1)
241 @x=@lMargin
242 w=@w-@rMargin-@x
243 wmax=(w-2*@cMargin)*1000/@FontSize
241 @x=@l_margin
242 w=@w-@r_margin-@x
243 wmax=(w-2*@c_margin)*1000/@font_size
244 244 end
245 245 nl+=1
246 246 next
@@ -252,12 +252,12 UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
252 252 if(l>wmax)
253 253 #Automatic line break
254 254 if(sep==-1 or i==j)
255 if(@x>@lMargin)
255 if(@x>@l_margin)
256 256 #Move to next line
257 @x=@lMargin
257 @x=@l_margin
258 258 @y+=h
259 w=@w-@rMargin-@x
260 wmax=(w-2*@cMargin)*1000/@FontSize
259 w=@w-@r_margin-@x
260 wmax=(w-2*@c_margin)*1000/@font_size
261 261 i+=1
262 262 nl+=1
263 263 next
@@ -274,9 +274,9 UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
274 274 j=i
275 275 l=0
276 276 if(nl==1)
277 @x=@lMargin
278 w=@w-@rMargin-@x
279 wmax=(w-2*@cMargin)*1000/@FontSize
277 @x=@l_margin
278 w=@w-@r_margin-@x
279 wmax=(w-2*@c_margin)*1000/@font_size
280 280 end
281 281 nl+=1
282 282 else
@@ -285,7 +285,7 UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
285 285 end
286 286 #Last chunk
287 287 if(i!=j)
288 Cell(l/1000*@FontSize,h,s[j,i-j],0,0,'',0,link)
288 Cell(l/1000*@font_size,h,s[j,i-j],0,0,'',0,link)
289 289 end
290 290 end
291 291
@@ -301,10 +301,10 private
301 301 end
302 302 # mqr=get_magic_quotes_runtime()
303 303 # set_magic_quotes_runtime(0)
304 @FontFiles.each_pair do |file, info|
304 @font_files.each_pair do |file, info|
305 305 #Font file embedding
306 306 newobj()
307 @FontFiles[file]['n']=@n
307 @font_files[file]['n']=@n
308 308 if(defined('FPDF_FONTPATH'))
309 309 file=FPDF_FONTPATH+file
310 310 end
@@ -378,7 +378,7 private
378 378 end
379 379 file=font['file']
380 380 if(file)
381 s+=' /FontFile'+(font['type']=='Type1' ? '' : '2')+' '+@FontFiles[file]['n']+' 0 R'
381 s+=' /FontFile'+(font['type']=='Type1' ? '' : '2')+' '+@font_files[file]['n']+' 0 R'
382 382 end
383 383 out(s+'>>')
384 384 out('endobj')
General Comments 0
You need to be logged in to leave comments. Login now