@@ -98,7 +98,7 module Redmine | |||||
98 |
|
98 | |||
99 | def textstring(s) |
|
99 | def textstring(s) | |
100 | # Format a text string |
|
100 | # Format a text string | |
101 |
if s |
|
101 | if s =~ /^</ # This means the string is hex-dumped. | |
102 | return s |
|
102 | return s | |
103 | else |
|
103 | else | |
104 | return '('+escape(s)+')' |
|
104 | return '('+escape(s)+')' | |
@@ -146,11 +146,21 module Redmine | |||||
146 | end |
|
146 | end | |
147 |
|
147 | |||
148 | def Bookmark(txt, level=0, y=0) |
|
148 | def Bookmark(txt, level=0, y=0) | |
149 | utf16 = Iconv.conv('UTF-16', 'UTF-8', txt) |
|
|||
150 | if (y == -1) |
|
149 | if (y == -1) | |
151 | y = GetY() |
|
150 | y = GetY() | |
152 | end |
|
151 | end | |
153 |
@outlines << {:t => |
|
152 | @outlines << {:t => txt, :l => level, :p => PageNo(), :y => (@h - y)*@k} | |
|
153 | end | |||
|
154 | ||||
|
155 | def bookmark_title(txt) | |||
|
156 | txt = begin | |||
|
157 | utf16txt = Iconv.conv('UTF-16BE', 'UTF-8', txt) | |||
|
158 | hextxt = "<FEFF" # FEFF is BOM | |||
|
159 | hextxt << utf16txt.unpack("C*").map {|x| sprintf("%02X",x) }.join | |||
|
160 | hextxt << ">" | |||
|
161 | rescue | |||
|
162 | txt | |||
|
163 | end || '' | |||
154 | end |
|
164 | end | |
155 |
|
165 | |||
156 | def putbookmarks |
|
166 | def putbookmarks | |
@@ -184,7 +194,7 module Redmine | |||||
184 | n=self.n+1 |
|
194 | n=self.n+1 | |
185 | @outlines.each_with_index do |o, i| |
|
195 | @outlines.each_with_index do |o, i| | |
186 | newobj() |
|
196 | newobj() | |
187 |
out('<</Title '+ |
|
197 | out('<</Title '+bookmark_title(o[:t])) | |
188 | out("/Parent #{n+o[:parent]} 0 R") |
|
198 | out("/Parent #{n+o[:parent]} 0 R") | |
189 | if (o[:prev]) |
|
199 | if (o[:prev]) | |
190 | out("/Prev #{n+o[:prev]} 0 R") |
|
200 | out("/Prev #{n+o[:prev]} 0 R") |
General Comments 0
You need to be logged in to leave comments.
Login now