##// END OF EJS Templates
Fixed: some quotation marks are rendered as strange characters in pdf....
Jean-Philippe Lang -
r858:d9e6359a839d
parent child
Show More
@@ -1,78 +1,80
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 # these quotation marks are not correctly rendered in the pdf
56 txt = txt.gsub(/[“”]/, '"') if txt
55 txt = begin
57 txt = begin
56 # 0x5c char handling
58 # 0x5c char handling
57 txtar = txt.split('\\')
59 txtar = txt.split('\\')
58 txtar << '' if txt[-1] == ?\\
60 txtar << '' if txt[-1] == ?\\
59 txtar.collect {|x| @ic.iconv(x)}.join('\\').gsub(/\\/, "\\\\\\\\")
61 txtar.collect {|x| @ic.iconv(x)}.join('\\').gsub(/\\/, "\\\\\\\\")
60 rescue
62 rescue
61 txt
63 txt
62 end || ''
64 end || ''
63 super w,h,txt,border,ln,align,fill,link
65 super w,h,txt,border,ln,align,fill,link
64 end
66 end
65
67
66 def Footer
68 def Footer
67 SetFont(@font_for_footer, 'I', 8)
69 SetFont(@font_for_footer, 'I', 8)
68 SetY(-15)
70 SetY(-15)
69 SetX(15)
71 SetX(15)
70 Cell(0, 5, @footer_date, 0, 0, 'L')
72 Cell(0, 5, @footer_date, 0, 0, 'L')
71 SetY(-15)
73 SetY(-15)
72 SetX(-30)
74 SetX(-30)
73 Cell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
75 Cell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
74 end
76 end
75
77
76 end
78 end
77
79
78 end
80 end
General Comments 0
You need to be logged in to leave comments. Login now