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