]> source.dussan.org Git - redmine.git/commitdiff
Scramble PDF title (#1204).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 4 Jan 2009 14:54:19 +0000 (14:54 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 4 Jan 2009 14:54:19 +0000 (14:54 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2233 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/export/pdf.rb

index 68e34b65ebb67c00e86226f2638838ddcba47f8f..5d75494edceafc73752d502c83f2b20f6854288b 100644 (file)
@@ -55,6 +55,27 @@ module Redmine
         def SetFontStyle(style, size)
           SetFont(@font_for_content, style, size)
         end
+        
+        def SetTitle(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 || ''
+          super(txt)
+        end
+    
+        def textstring(s)
+          # Format a text string
+          if s =~ /^</  # This means the string is hex-dumped.
+            return s
+          else
+            return '('+escape(s)+')'
+          end
+        end
           
         def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
           @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')