@@ -76,6 +76,8 module Redmine | |||||
76 | end |
|
76 | end | |
77 | SetCreator(Redmine::Info.app_name) |
|
77 | SetCreator(Redmine::Info.app_name) | |
78 | SetFont(@font_for_content) |
|
78 | SetFont(@font_for_content) | |
|
79 | @outlines = [] | |||
|
80 | @outlineRoot = nil | |||
79 | end |
|
81 | end | |
80 |
|
82 | |||
81 | def SetFontStyle(style, size) |
|
83 | def SetFontStyle(style, size) | |
@@ -142,6 +144,84 module Redmine | |||||
142 | SetX(-30) |
|
144 | SetX(-30) | |
143 | RDMCell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C') |
|
145 | RDMCell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C') | |
144 | end |
|
146 | end | |
|
147 | ||||
|
148 | def Bookmark(txt, level=0, y=0) | |||
|
149 | utf16 = Iconv.conv('UTF-16', 'UTF-8', txt) | |||
|
150 | if (y == -1) | |||
|
151 | y = GetY() | |||
|
152 | end | |||
|
153 | @outlines << {:t => utf16, :l => level, :p => PageNo(), :y => (@h - y)*@k} | |||
|
154 | end | |||
|
155 | ||||
|
156 | def putbookmarks | |||
|
157 | nb=@outlines.size | |||
|
158 | return if (nb==0) | |||
|
159 | lru=[] | |||
|
160 | level=0 | |||
|
161 | @outlines.each_with_index do |o, i| | |||
|
162 | if(o[:l]>0) | |||
|
163 | parent=lru[o[:l]-1] | |||
|
164 | #Set parent and last pointers | |||
|
165 | @outlines[i][:parent]=parent | |||
|
166 | @outlines[parent][:last]=i | |||
|
167 | if (o[:l]>level) | |||
|
168 | #Level increasing: set first pointer | |||
|
169 | @outlines[parent][:first]=i | |||
|
170 | end | |||
|
171 | else | |||
|
172 | @outlines[i][:parent]=nb | |||
|
173 | end | |||
|
174 | if (o[:l]<=level && i>0) | |||
|
175 | #Set prev and next pointers | |||
|
176 | prev=lru[o[:l]] | |||
|
177 | @outlines[prev][:next]=i | |||
|
178 | @outlines[i][:prev]=prev | |||
|
179 | end | |||
|
180 | lru[o[:l]]=i | |||
|
181 | level=o[:l] | |||
|
182 | end | |||
|
183 | #Outline items | |||
|
184 | n=self.n+1 | |||
|
185 | @outlines.each_with_index do |o, i| | |||
|
186 | newobj() | |||
|
187 | out('<</Title '+textstring(o[:t])) | |||
|
188 | out("/Parent #{n+o[:parent]} 0 R") | |||
|
189 | if (o[:prev]) | |||
|
190 | out("/Prev #{n+o[:prev]} 0 R") | |||
|
191 | end | |||
|
192 | if (o[:next]) | |||
|
193 | out("/Next #{n+o[:next]} 0 R") | |||
|
194 | end | |||
|
195 | if (o[:first]) | |||
|
196 | out("/First #{n+o[:first]} 0 R") | |||
|
197 | end | |||
|
198 | if (o[:last]) | |||
|
199 | out("/Last #{n+o[:last]} 0 R") | |||
|
200 | end | |||
|
201 | out("/Dest [%d 0 R /XYZ 0 %.2f null]" % [1+2*o[:p], o[:y]]) | |||
|
202 | out('/Count 0>>') | |||
|
203 | out('endobj') | |||
|
204 | end | |||
|
205 | #Outline root | |||
|
206 | newobj() | |||
|
207 | @outlineRoot=self.n | |||
|
208 | out("<</Type /Outlines /First #{n} 0 R"); | |||
|
209 | out("/Last #{n+lru[0]} 0 R>>"); | |||
|
210 | out('endobj'); | |||
|
211 | end | |||
|
212 | ||||
|
213 | def putresources() | |||
|
214 | super | |||
|
215 | putbookmarks() | |||
|
216 | end | |||
|
217 | ||||
|
218 | def putcatalog() | |||
|
219 | super | |||
|
220 | if(@outlines.size > 0) | |||
|
221 | out("/Outlines #{@outlineRoot} 0 R"); | |||
|
222 | out('/PageMode /UseOutlines'); | |||
|
223 | end | |||
|
224 | end | |||
145 | end |
|
225 | end | |
146 |
|
226 | |||
147 | # Returns a PDF string of a list of issues |
|
227 | # Returns a PDF string of a list of issues | |
@@ -205,9 +285,10 module Redmine | |||||
205 | if query.grouped? && |
|
285 | if query.grouped? && | |
206 | (group = query.group_by_column.value(issue)) != previous_group |
|
286 | (group = query.group_by_column.value(issue)) != previous_group | |
207 | pdf.SetFontStyle('B',9) |
|
287 | pdf.SetFontStyle('B',9) | |
208 | pdf.RDMCell(277, row_height, |
|
288 | group_label = group.blank? ? 'None' : group.to_s | |
209 |
|
|
289 | group_label << " (#{query.issue_count_by_group[group]})" | |
210 | 1, 1, 'L') |
|
290 | pdf.Bookmark group_label, 0, -1 | |
|
291 | pdf.RDMCell(277, row_height, group_label, 1, 1, 'L') | |||
211 | pdf.SetFontStyle('',8) |
|
292 | pdf.SetFontStyle('',8) | |
212 | previous_group = group |
|
293 | previous_group = group | |
213 | end |
|
294 | end |
General Comments 0
You need to be logged in to leave comments.
Login now