summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-05-09 06:46:21 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-05-09 06:46:21 +0000
commit48a6fb45a7297886344d65d7d91bd6cd0bc2e763 (patch)
tree90a5764b76166d6989cd882cfa8b789edf5e2fcd
parente25dd95389431dfb91e196b1351babd4ab11c52a (diff)
downloadredmine-48a6fb45a7297886344d65d7d91bd6cd0bc2e763.tar.gz
redmine-48a6fb45a7297886344d65d7d91bd6cd0bc2e763.zip
PDF: replace invalid UTF-8 sequences in TCPDF (#61, #8312).
There is no guarantees that database strings are valid UTF-8 in Ruby 1.8 MySQL and SQLite3. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5716 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--lib/redmine/export/pdf.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/redmine/export/pdf.rb b/lib/redmine/export/pdf.rb
index 448f7273f..295911354 100644
--- a/lib/redmine/export/pdf.rb
+++ b/lib/redmine/export/pdf.rb
@@ -35,6 +35,9 @@ module Redmine
def initialize(lang)
super()
+ if RUBY_VERSION < '1.9'
+ @ic = Iconv.new(l(:general_pdf_encoding), 'UTF-8')
+ end
set_language_if_valid lang
@font_for_content = 'FreeSans'
@font_for_footer = 'FreeSans'
@@ -67,8 +70,17 @@ module Redmine
end
end
- alias RDMCell Cell
- alias RDMMultiCell MultiCell
+ def fix_text_encoding(txt)
+ RDMPdfEncoding::rdm_pdf_iconv(@ic, txt)
+ end
+
+ def RDMCell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
+ Cell(w,h,fix_text_encoding(txt),border,ln,align,fill,link)
+ end
+
+ def RDMMultiCell(w,h=0,txt='',border=0,align='',fill=0)
+ MultiCell(w,h,fix_text_encoding(txt),border,align,fill)
+ end
def Footer
SetFont(@font_for_footer, 'I', 8)