##// END OF EJS Templates
Fixed: improper 0x5c char handling in PDF output (Go Maeda)....
Jean-Philippe Lang -
r802:bb724e75c0a9
parent child
Show More
@@ -1,75 +1,78
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require 'iconv'
18 require 'iconv'
19 require 'rfpdf/chinese'
19 require 'rfpdf/chinese'
20
20
21 module IfpdfHelper
21 module IfpdfHelper
22
22
23 class IFPDF < FPDF
23 class IFPDF < FPDF
24 include GLoc
24 include GLoc
25 attr_accessor :footer_date
25 attr_accessor :footer_date
26
26
27 def initialize(lang)
27 def initialize(lang)
28 super()
28 super()
29 set_language_if_valid lang
29 set_language_if_valid lang
30 case current_language
30 case current_language
31 when :ja
31 when :ja
32 extend(PDF_Japanese)
32 extend(PDF_Japanese)
33 AddSJISFont()
33 AddSJISFont()
34 @font_for_content = 'SJIS'
34 @font_for_content = 'SJIS'
35 @font_for_footer = 'SJIS'
35 @font_for_footer = 'SJIS'
36 when :zh
36 when :zh
37 extend(PDF_Chinese)
37 extend(PDF_Chinese)
38 AddBig5Font()
38 AddBig5Font()
39 @font_for_content = 'Big5'
39 @font_for_content = 'Big5'
40 @font_for_footer = 'Big5'
40 @font_for_footer = 'Big5'
41 else
41 else
42 @font_for_content = 'Arial'
42 @font_for_content = 'Arial'
43 @font_for_footer = 'Helvetica'
43 @font_for_footer = 'Helvetica'
44 end
44 end
45 SetCreator("redMine #{Redmine::VERSION}")
45 SetCreator("redMine #{Redmine::VERSION}")
46 SetFont(@font_for_content)
46 SetFont(@font_for_content)
47 end
47 end
48
48
49 def SetFontStyle(style, size)
49 def SetFontStyle(style, size)
50 SetFont(@font_for_content, style, size)
50 SetFont(@font_for_content, style, size)
51 end
51 end
52
52
53 def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
53 def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
54 @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')
54 @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')
55 txt = begin
55 txt = begin
56 @ic.iconv(txt)
56 # 0x5c char handling
57 txtar = txt.split('\\')
58 txtar << '' if txt[-1] == ?\\
59 txtar.collect {|x| @ic.iconv(x)}.join('\\').gsub(/\\/, "\\\\\\\\")
57 rescue
60 rescue
58 txt
61 txt
59 end
62 end || ''
60 super w,h,txt,border,ln,align,fill,link
63 super w,h,txt,border,ln,align,fill,link
61 end
64 end
62
65
63 def Footer
66 def Footer
64 SetFont(@font_for_footer, 'I', 8)
67 SetFont(@font_for_footer, 'I', 8)
65 SetY(-15)
68 SetY(-15)
66 SetX(15)
69 SetX(15)
67 Cell(0, 5, @footer_date, 0, 0, 'L')
70 Cell(0, 5, @footer_date, 0, 0, 'L')
68 SetY(-15)
71 SetY(-15)
69 SetX(-30)
72 SetX(-30)
70 Cell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
73 Cell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
71 end
74 end
72
75
73 end
76 end
74
77
75 end
78 end
General Comments 0
You need to be logged in to leave comments. Login now