diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-03-01 19:49:04 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-03-01 19:49:04 +0000 |
commit | 6a875eb691844b78786d95d45e3c457bc67fc9a2 (patch) | |
tree | 387b24c7d7d1099505ed715f0bd3465413041cff /app/helpers | |
parent | 83c96d4f3ef2adb8ec3226f82bc68e8f1accd6d9 (diff) | |
download | redmine-6a875eb691844b78786d95d45e3c457bc67fc9a2.tar.gz redmine-6a875eb691844b78786d95d45e3c457bc67fc9a2.zip |
fix for #8973: Export feature(to csv/pdf) doesn't work in Japanese
csv and pdf encoding are know defined for each language (general_csv_encoding and general_pdf_encoding keys in lang files)
added SJIS font for japanese pdf exports
git-svn-id: http://redmine.rubyforge.org/svn/trunk@287 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/ifpdf_helper.rb | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/app/helpers/ifpdf_helper.rb b/app/helpers/ifpdf_helper.rb index 7c1e3107e..481c2c318 100644 --- a/app/helpers/ifpdf_helper.rb +++ b/app/helpers/ifpdf_helper.rb @@ -16,20 +16,37 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'iconv'
+require 'rfpdf/chinese'
-module IfpdfHelper
-
+module IfpdfHelper
+
class IFPDF < FPDF
-
+ include GLoc
attr_accessor :footer_date
- def initialize
- super
+ def initialize(lang)
+ super()
+ set_language_if_valid lang
+ case current_language
+ when :ja
+ extend(PDF_Japanese)
+ AddSJISFont()
+ @font_for_content = 'SJIS'
+ @font_for_footer = 'SJIS'
+ else
+ @font_for_content = 'Arial'
+ @font_for_footer = 'Helvetica'
+ end
SetCreator("redMine #{Redmine::VERSION}")
+ SetFont(@font_for_content)
+ end
+
+ def SetFontStyle(style, size)
+ SetFont(@font_for_content, style, size)
end
def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
- @ic ||= Iconv.new('ISO-8859-1', 'UTF-8')
+ @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')
txt = begin
@ic.iconv(txt)
rescue
@@ -39,7 +56,7 @@ module IfpdfHelper end
def Footer
- SetFont('Helvetica', 'I', 8)
+ SetFont(@font_for_footer, 'I', 8)
SetY(-15)
SetX(15)
Cell(0, 5, @footer_date, 0, 0, 'L')
|