diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-01-30 22:53:53 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-01-30 22:53:53 +0000 |
commit | 7abaa570c607cfe7387c04bd32438154345fd02c (patch) | |
tree | 224ae32faad5307bd2ef536fbeb6867a959ec80a /lib | |
parent | 682efe399dcc46e4b7f63bfa55c0633820e32508 (diff) | |
download | redmine-7abaa570c607cfe7387c04bd32438154345fd02c.tar.gz redmine-7abaa570c607cfe7387c04bd32438154345fd02c.zip |
Fix for ruby1.9.3.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8739 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r-- | lib/redmine/export/pdf.rb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/redmine/export/pdf.rb b/lib/redmine/export/pdf.rb index f6d6f8cb1..f44612c6f 100644 --- a/lib/redmine/export/pdf.rb +++ b/lib/redmine/export/pdf.rb @@ -98,7 +98,7 @@ module Redmine def textstring(s) # Format a text string - if s.chars.first == '<' # This means the string is hex-dumped. + if s =~ /^</ # This means the string is hex-dumped. return s else return '('+escape(s)+')' @@ -146,11 +146,21 @@ module Redmine end def Bookmark(txt, level=0, y=0) - utf16 = Iconv.conv('UTF-16', 'UTF-8', txt) if (y == -1) y = GetY() end - @outlines << {:t => utf16, :l => level, :p => PageNo(), :y => (@h - y)*@k} + @outlines << {:t => txt, :l => level, :p => PageNo(), :y => (@h - y)*@k} + end + + def bookmark_title(txt) + txt = begin + utf16txt = Iconv.conv('UTF-16BE', 'UTF-8', txt) + hextxt = "<FEFF" # FEFF is BOM + hextxt << utf16txt.unpack("C*").map {|x| sprintf("%02X",x) }.join + hextxt << ">" + rescue + txt + end || '' end def putbookmarks @@ -184,7 +194,7 @@ module Redmine n=self.n+1 @outlines.each_with_index do |o, i| newobj() - out('<</Title '+textstring(o[:t])) + out('<</Title '+bookmark_title(o[:t])) out("/Parent #{n+o[:parent]} 0 R") if (o[:prev]) out("/Prev #{n+o[:prev]} 0 R") |