@@ -120,94 +120,6 module Redmine | |||||
120 | end |
|
120 | end | |
121 | end |
|
121 | end | |
122 |
|
122 | |||
123 | class IFPDF < FPDF |
|
|||
124 | include Redmine::I18n |
|
|||
125 | attr_accessor :footer_date |
|
|||
126 |
|
||||
127 | def initialize(lang) |
|
|||
128 | super() |
|
|||
129 | if RUBY_VERSION < '1.9' |
|
|||
130 | @ic = Iconv.new(l(:general_pdf_encoding), 'UTF-8') |
|
|||
131 | end |
|
|||
132 | set_language_if_valid lang |
|
|||
133 | case l(:general_pdf_encoding).upcase |
|
|||
134 | when 'CP949' |
|
|||
135 | extend(PDF_Korean) |
|
|||
136 | AddUHCFont() |
|
|||
137 | @font_for_content = 'UHC' |
|
|||
138 | @font_for_footer = 'UHC' |
|
|||
139 | when 'CP932' |
|
|||
140 | extend(PDF_Japanese) |
|
|||
141 | AddSJISFont() |
|
|||
142 | @font_for_content = 'SJIS' |
|
|||
143 | @font_for_footer = 'SJIS' |
|
|||
144 | when 'GB18030' |
|
|||
145 | extend(PDF_Chinese) |
|
|||
146 | AddGBFont() |
|
|||
147 | @font_for_content = 'GB' |
|
|||
148 | @font_for_footer = 'GB' |
|
|||
149 | when 'BIG5' |
|
|||
150 | extend(PDF_Chinese) |
|
|||
151 | AddBig5Font() |
|
|||
152 | @font_for_content = 'Big5' |
|
|||
153 | @font_for_footer = 'Big5' |
|
|||
154 | else |
|
|||
155 | @font_for_content = 'Arial' |
|
|||
156 | @font_for_footer = 'Helvetica' |
|
|||
157 | end |
|
|||
158 | SetCreator(Redmine::Info.app_name) |
|
|||
159 | SetFont(@font_for_content) |
|
|||
160 | end |
|
|||
161 |
|
||||
162 | def SetFontStyle(style, size) |
|
|||
163 | SetFont(@font_for_content, style, size) |
|
|||
164 | end |
|
|||
165 |
|
||||
166 | def SetTitle(txt) |
|
|||
167 | txt = begin |
|
|||
168 | utf16txt = Iconv.conv('UTF-16BE', 'UTF-8', txt) |
|
|||
169 | hextxt = "<FEFF" # FEFF is BOM |
|
|||
170 | hextxt << utf16txt.unpack("C*").map {|x| sprintf("%02X",x) }.join |
|
|||
171 | hextxt << ">" |
|
|||
172 | rescue |
|
|||
173 | txt |
|
|||
174 | end || '' |
|
|||
175 | super(txt) |
|
|||
176 | end |
|
|||
177 |
|
||||
178 | def textstring(s) |
|
|||
179 | # Format a text string |
|
|||
180 | if s =~ /^</ # This means the string is hex-dumped. |
|
|||
181 | return s |
|
|||
182 | else |
|
|||
183 | return '('+escape(s)+')' |
|
|||
184 | end |
|
|||
185 | end |
|
|||
186 |
|
||||
187 | def fix_text_encoding(txt) |
|
|||
188 | RDMPdfEncoding::rdm_pdf_iconv(@ic, txt) |
|
|||
189 | end |
|
|||
190 |
|
||||
191 | def RDMCell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='') |
|
|||
192 | Cell(w,h,fix_text_encoding(txt),border,ln,align,fill,link) |
|
|||
193 | end |
|
|||
194 |
|
||||
195 | def RDMMultiCell(w,h=0,txt='',border=0,align='',fill=0) |
|
|||
196 | MultiCell(w,h,fix_text_encoding(txt),border,align,fill) |
|
|||
197 | end |
|
|||
198 |
|
||||
199 | def Footer |
|
|||
200 | SetFont(@font_for_footer, 'I', 8) |
|
|||
201 | SetY(-15) |
|
|||
202 | SetX(15) |
|
|||
203 | RDMCell(0, 5, @footer_date, 0, 0, 'L') |
|
|||
204 | SetY(-15) |
|
|||
205 | SetX(-30) |
|
|||
206 | RDMCell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C') |
|
|||
207 | end |
|
|||
208 | alias alias_nb_pages AliasNbPages |
|
|||
209 | end |
|
|||
210 |
|
||||
211 | # Returns a PDF string of a list of issues |
|
123 | # Returns a PDF string of a list of issues | |
212 | def issues_to_pdf(issues, project, query) |
|
124 | def issues_to_pdf(issues, project, query) | |
213 | pdf = ITCPDF.new(current_language) |
|
125 | pdf = ITCPDF.new(current_language) |
General Comments 0
You need to be logged in to leave comments.
Login now