annotate lib/redmine/export/pdf.rb @ 905:a97ce6b60fde yuya

Close obsolete branch yuya
author Chris Cannam
date Sat, 18 Sep 2010 17:38:00 +0100
parents cca12e1c1fd4
children 40f7cfd4df19
rev   line source
Chris@0 1 # encoding: utf-8
Chris@0 2 #
Chris@0 3 # Redmine - project management software
Chris@0 4 # Copyright (C) 2006-2009 Jean-Philippe Lang
Chris@0 5 #
Chris@0 6 # This program is free software; you can redistribute it and/or
Chris@0 7 # modify it under the terms of the GNU General Public License
Chris@0 8 # as published by the Free Software Foundation; either version 2
Chris@0 9 # of the License, or (at your option) any later version.
Chris@0 10 #
Chris@0 11 # This program is distributed in the hope that it will be useful,
Chris@0 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@0 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 14 # GNU General Public License for more details.
Chris@0 15 #
Chris@0 16 # You should have received a copy of the GNU General Public License
Chris@0 17 # along with this program; if not, write to the Free Software
Chris@0 18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@0 19
Chris@0 20 require 'iconv'
Chris@0 21 require 'rfpdf/fpdf'
Chris@0 22 require 'rfpdf/chinese'
Chris@0 23
Chris@0 24 module Redmine
Chris@0 25 module Export
Chris@0 26 module PDF
Chris@0 27 include ActionView::Helpers::TextHelper
Chris@0 28 include ActionView::Helpers::NumberHelper
Chris@0 29
Chris@0 30 class IFPDF < FPDF
Chris@0 31 include Redmine::I18n
Chris@0 32 attr_accessor :footer_date
Chris@0 33
Chris@0 34 def initialize(lang)
Chris@0 35 super()
Chris@0 36 set_language_if_valid lang
Chris@0 37 case current_language.to_s.downcase
Chris@0 38 when 'ko'
Chris@0 39 extend(PDF_Korean)
Chris@0 40 AddUHCFont()
Chris@0 41 @font_for_content = 'UHC'
Chris@0 42 @font_for_footer = 'UHC'
Chris@0 43 when 'ja'
Chris@0 44 extend(PDF_Japanese)
Chris@0 45 AddSJISFont()
Chris@0 46 @font_for_content = 'SJIS'
Chris@0 47 @font_for_footer = 'SJIS'
Chris@0 48 when 'zh'
Chris@0 49 extend(PDF_Chinese)
Chris@0 50 AddGBFont()
Chris@0 51 @font_for_content = 'GB'
Chris@0 52 @font_for_footer = 'GB'
Chris@0 53 when 'zh-tw'
Chris@0 54 extend(PDF_Chinese)
Chris@0 55 AddBig5Font()
Chris@0 56 @font_for_content = 'Big5'
Chris@0 57 @font_for_footer = 'Big5'
Chris@0 58 else
Chris@0 59 @font_for_content = 'Arial'
Chris@0 60 @font_for_footer = 'Helvetica'
Chris@0 61 end
Chris@0 62 SetCreator(Redmine::Info.app_name)
Chris@0 63 SetFont(@font_for_content)
Chris@0 64 end
Chris@0 65
Chris@0 66 def SetFontStyle(style, size)
Chris@0 67 SetFont(@font_for_content, style, size)
Chris@0 68 end
Chris@0 69
Chris@0 70 def SetTitle(txt)
Chris@0 71 txt = begin
Chris@0 72 utf16txt = Iconv.conv('UTF-16BE', 'UTF-8', txt)
Chris@0 73 hextxt = "<FEFF" # FEFF is BOM
Chris@0 74 hextxt << utf16txt.unpack("C*").map {|x| sprintf("%02X",x) }.join
Chris@0 75 hextxt << ">"
Chris@0 76 rescue
Chris@0 77 txt
Chris@0 78 end || ''
Chris@0 79 super(txt)
Chris@0 80 end
Chris@0 81
Chris@0 82 def textstring(s)
Chris@0 83 # Format a text string
Chris@0 84 if s =~ /^</ # This means the string is hex-dumped.
Chris@0 85 return s
Chris@0 86 else
Chris@0 87 return '('+escape(s)+')'
Chris@0 88 end
Chris@0 89 end
Chris@0 90
Chris@0 91 def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
Chris@0 92 @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')
Chris@0 93 # these quotation marks are not correctly rendered in the pdf
Chris@0 94 txt = txt.gsub(/[“�]/, '"') if txt
Chris@0 95 txt = begin
Chris@0 96 # 0x5c char handling
Chris@0 97 txtar = txt.split('\\')
Chris@0 98 txtar << '' if txt[-1] == ?\\
Chris@0 99 txtar.collect {|x| @ic.iconv(x)}.join('\\').gsub(/\\/, "\\\\\\\\")
Chris@0 100 rescue
Chris@0 101 txt
Chris@0 102 end || ''
Chris@0 103 super w,h,txt,border,ln,align,fill,link
Chris@0 104 end
Chris@0 105
Chris@0 106 def Footer
Chris@0 107 SetFont(@font_for_footer, 'I', 8)
Chris@0 108 SetY(-15)
Chris@0 109 SetX(15)
Chris@0 110 Cell(0, 5, @footer_date, 0, 0, 'L')
Chris@0 111 SetY(-15)
Chris@0 112 SetX(-30)
Chris@0 113 Cell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
Chris@0 114 end
Chris@0 115 end
Chris@0 116
Chris@0 117 # Returns a PDF string of a list of issues
Chris@0 118 def issues_to_pdf(issues, project, query)
Chris@0 119 pdf = IFPDF.new(current_language)
Chris@0 120 title = query.new_record? ? l(:label_issue_plural) : query.name
Chris@0 121 title = "#{project} - #{title}" if project
Chris@0 122 pdf.SetTitle(title)
Chris@0 123 pdf.AliasNbPages
Chris@0 124 pdf.footer_date = format_date(Date.today)
Chris@0 125 pdf.AddPage("L")
Chris@0 126
Chris@0 127 row_height = 6
Chris@0 128 col_width = []
Chris@0 129 unless query.columns.empty?
Chris@0 130 col_width = query.columns.collect {|column| column.name == :subject ? 4.0 : 1.0 }
Chris@0 131 ratio = 262.0 / col_width.inject(0) {|s,w| s += w}
Chris@0 132 col_width = col_width.collect {|w| w * ratio}
Chris@0 133 end
Chris@0 134
Chris@0 135 # title
Chris@0 136 pdf.SetFontStyle('B',11)
Chris@0 137 pdf.Cell(190,10, title)
Chris@0 138 pdf.Ln
Chris@0 139
Chris@0 140 # headers
Chris@0 141 pdf.SetFontStyle('B',8)
Chris@0 142 pdf.SetFillColor(230, 230, 230)
Chris@0 143 pdf.Cell(15, row_height, "#", 1, 0, 'L', 1)
Chris@0 144 query.columns.each_with_index do |column, i|
Chris@0 145 pdf.Cell(col_width[i], row_height, column.caption, 1, 0, 'L', 1)
Chris@0 146 end
Chris@0 147 pdf.Ln
Chris@0 148
Chris@0 149 # rows
Chris@0 150 pdf.SetFontStyle('',8)
Chris@0 151 pdf.SetFillColor(255, 255, 255)
Chris@0 152 previous_group = false
Chris@0 153 issues.each do |issue|
Chris@0 154 if query.grouped? && (group = query.group_by_column.value(issue)) != previous_group
Chris@0 155 pdf.SetFontStyle('B',9)
Chris@0 156 pdf.Cell(277, row_height,
Chris@0 157 (group.blank? ? 'None' : group.to_s) + " (#{@issue_count_by_group[group]})",
Chris@0 158 1, 1, 'L')
Chris@0 159 pdf.SetFontStyle('',8)
Chris@0 160 previous_group = group
Chris@0 161 end
Chris@0 162 pdf.Cell(15, row_height, issue.id.to_s, 1, 0, 'L', 1)
Chris@0 163 query.columns.each_with_index do |column, i|
Chris@0 164 s = if column.is_a?(QueryCustomFieldColumn)
Chris@0 165 cv = issue.custom_values.detect {|v| v.custom_field_id == column.custom_field.id}
Chris@0 166 show_value(cv)
Chris@0 167 else
Chris@0 168 value = issue.send(column.name)
Chris@0 169 if value.is_a?(Date)
Chris@0 170 format_date(value)
Chris@0 171 elsif value.is_a?(Time)
Chris@0 172 format_time(value)
Chris@0 173 else
Chris@0 174 value
Chris@0 175 end
Chris@0 176 end
Chris@0 177 pdf.Cell(col_width[i], row_height, s.to_s, 1, 0, 'L', 1)
Chris@0 178 end
Chris@0 179 pdf.Ln
Chris@0 180 end
Chris@0 181 if issues.size == Setting.issues_export_limit.to_i
Chris@0 182 pdf.SetFontStyle('B',10)
Chris@0 183 pdf.Cell(0, row_height, '...')
Chris@0 184 end
Chris@0 185 pdf.Output
Chris@0 186 end
Chris@0 187
Chris@0 188 # Returns a PDF string of a single issue
Chris@0 189 def issue_to_pdf(issue)
Chris@0 190 pdf = IFPDF.new(current_language)
Chris@0 191 pdf.SetTitle("#{issue.project} - ##{issue.tracker} #{issue.id}")
Chris@0 192 pdf.AliasNbPages
Chris@0 193 pdf.footer_date = format_date(Date.today)
Chris@0 194 pdf.AddPage
Chris@0 195
Chris@0 196 pdf.SetFontStyle('B',11)
Chris@0 197 pdf.Cell(190,10, "#{issue.project} - #{issue.tracker} # #{issue.id}: #{issue.subject}")
Chris@0 198 pdf.Ln
Chris@0 199
Chris@0 200 y0 = pdf.GetY
Chris@0 201
Chris@0 202 pdf.SetFontStyle('B',9)
Chris@0 203 pdf.Cell(35,5, l(:field_status) + ":","LT")
Chris@0 204 pdf.SetFontStyle('',9)
Chris@0 205 pdf.Cell(60,5, issue.status.to_s,"RT")
Chris@0 206 pdf.SetFontStyle('B',9)
Chris@0 207 pdf.Cell(35,5, l(:field_priority) + ":","LT")
Chris@0 208 pdf.SetFontStyle('',9)
Chris@0 209 pdf.Cell(60,5, issue.priority.to_s,"RT")
Chris@0 210 pdf.Ln
Chris@0 211
Chris@0 212 pdf.SetFontStyle('B',9)
Chris@0 213 pdf.Cell(35,5, l(:field_author) + ":","L")
Chris@0 214 pdf.SetFontStyle('',9)
Chris@0 215 pdf.Cell(60,5, issue.author.to_s,"R")
Chris@0 216 pdf.SetFontStyle('B',9)
Chris@0 217 pdf.Cell(35,5, l(:field_category) + ":","L")
Chris@0 218 pdf.SetFontStyle('',9)
Chris@0 219 pdf.Cell(60,5, issue.category.to_s,"R")
Chris@0 220 pdf.Ln
Chris@0 221
Chris@0 222 pdf.SetFontStyle('B',9)
Chris@0 223 pdf.Cell(35,5, l(:field_created_on) + ":","L")
Chris@0 224 pdf.SetFontStyle('',9)
Chris@0 225 pdf.Cell(60,5, format_date(issue.created_on),"R")
Chris@0 226 pdf.SetFontStyle('B',9)
Chris@0 227 pdf.Cell(35,5, l(:field_assigned_to) + ":","L")
Chris@0 228 pdf.SetFontStyle('',9)
Chris@0 229 pdf.Cell(60,5, issue.assigned_to.to_s,"R")
Chris@0 230 pdf.Ln
Chris@0 231
Chris@0 232 pdf.SetFontStyle('B',9)
Chris@0 233 pdf.Cell(35,5, l(:field_updated_on) + ":","LB")
Chris@0 234 pdf.SetFontStyle('',9)
Chris@0 235 pdf.Cell(60,5, format_date(issue.updated_on),"RB")
Chris@0 236 pdf.SetFontStyle('B',9)
Chris@0 237 pdf.Cell(35,5, l(:field_due_date) + ":","LB")
Chris@0 238 pdf.SetFontStyle('',9)
Chris@0 239 pdf.Cell(60,5, format_date(issue.due_date),"RB")
Chris@0 240 pdf.Ln
Chris@0 241
Chris@0 242 for custom_value in issue.custom_field_values
Chris@0 243 pdf.SetFontStyle('B',9)
Chris@0 244 pdf.Cell(35,5, custom_value.custom_field.name + ":","L")
Chris@0 245 pdf.SetFontStyle('',9)
Chris@0 246 pdf.MultiCell(155,5, (show_value custom_value),"R")
Chris@0 247 end
Chris@0 248
Chris@0 249 pdf.SetFontStyle('B',9)
Chris@0 250 pdf.Cell(35,5, l(:field_subject) + ":","LTB")
Chris@0 251 pdf.SetFontStyle('',9)
Chris@0 252 pdf.Cell(155,5, issue.subject,"RTB")
Chris@0 253 pdf.Ln
Chris@0 254
Chris@0 255 pdf.SetFontStyle('B',9)
Chris@0 256 pdf.Cell(35,5, l(:field_description) + ":")
Chris@0 257 pdf.SetFontStyle('',9)
Chris@0 258 pdf.MultiCell(155,5, @issue.description,"BR")
Chris@0 259
Chris@0 260 pdf.Line(pdf.GetX, y0, pdf.GetX, pdf.GetY)
Chris@0 261 pdf.Line(pdf.GetX, pdf.GetY, 170, pdf.GetY)
Chris@0 262 pdf.Ln
Chris@0 263
Chris@0 264 if issue.changesets.any? && User.current.allowed_to?(:view_changesets, issue.project)
Chris@0 265 pdf.SetFontStyle('B',9)
Chris@0 266 pdf.Cell(190,5, l(:label_associated_revisions), "B")
Chris@0 267 pdf.Ln
Chris@0 268 for changeset in issue.changesets
Chris@0 269 pdf.SetFontStyle('B',8)
Chris@0 270 pdf.Cell(190,5, format_time(changeset.committed_on) + " - " + changeset.author.to_s)
Chris@0 271 pdf.Ln
Chris@0 272 unless changeset.comments.blank?
Chris@0 273 pdf.SetFontStyle('',8)
Chris@0 274 pdf.MultiCell(190,5, changeset.comments)
Chris@0 275 end
Chris@0 276 pdf.Ln
Chris@0 277 end
Chris@0 278 end
Chris@0 279
Chris@0 280 pdf.SetFontStyle('B',9)
Chris@0 281 pdf.Cell(190,5, l(:label_history), "B")
Chris@0 282 pdf.Ln
Chris@0 283 for journal in issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC")
Chris@0 284 pdf.SetFontStyle('B',8)
Chris@0 285 pdf.Cell(190,5, format_time(journal.created_on) + " - " + journal.user.name)
Chris@0 286 pdf.Ln
Chris@0 287 pdf.SetFontStyle('I',8)
Chris@0 288 for detail in journal.details
Chris@0 289 pdf.Cell(190,5, "- " + show_detail(detail, true))
Chris@0 290 pdf.Ln
Chris@0 291 end
Chris@0 292 if journal.notes?
Chris@0 293 pdf.SetFontStyle('',8)
Chris@0 294 pdf.MultiCell(190,5, journal.notes)
Chris@0 295 end
Chris@0 296 pdf.Ln
Chris@0 297 end
Chris@0 298
Chris@0 299 if issue.attachments.any?
Chris@0 300 pdf.SetFontStyle('B',9)
Chris@0 301 pdf.Cell(190,5, l(:label_attachment_plural), "B")
Chris@0 302 pdf.Ln
Chris@0 303 for attachment in issue.attachments
Chris@0 304 pdf.SetFontStyle('',8)
Chris@0 305 pdf.Cell(80,5, attachment.filename)
Chris@0 306 pdf.Cell(20,5, number_to_human_size(attachment.filesize),0,0,"R")
Chris@0 307 pdf.Cell(25,5, format_date(attachment.created_on),0,0,"R")
Chris@0 308 pdf.Cell(65,5, attachment.author.name,0,0,"R")
Chris@0 309 pdf.Ln
Chris@0 310 end
Chris@0 311 end
Chris@0 312 pdf.Output
Chris@0 313 end
Chris@0 314
Chris@0 315 # Returns a PDF string of a gantt chart
Chris@0 316 def gantt_to_pdf(gantt, project)
Chris@0 317 pdf = IFPDF.new(current_language)
Chris@0 318 pdf.SetTitle("#{l(:label_gantt)} #{project}")
Chris@0 319 pdf.AliasNbPages
Chris@0 320 pdf.footer_date = format_date(Date.today)
Chris@0 321 pdf.AddPage("L")
Chris@0 322 pdf.SetFontStyle('B',12)
Chris@0 323 pdf.SetX(15)
Chris@0 324 pdf.Cell(70, 20, project.to_s)
Chris@0 325 pdf.Ln
Chris@0 326 pdf.SetFontStyle('B',9)
Chris@0 327
Chris@1 328 subject_width = 100
Chris@0 329 header_heigth = 5
Chris@0 330
Chris@0 331 headers_heigth = header_heigth
Chris@0 332 show_weeks = false
Chris@0 333 show_days = false
Chris@0 334
Chris@0 335 if gantt.months < 7
Chris@0 336 show_weeks = true
Chris@0 337 headers_heigth = 2*header_heigth
Chris@0 338 if gantt.months < 3
Chris@0 339 show_days = true
Chris@0 340 headers_heigth = 3*header_heigth
Chris@0 341 end
Chris@0 342 end
Chris@0 343
Chris@1 344 g_width = 280 - subject_width
Chris@0 345 zoom = (g_width) / (gantt.date_to - gantt.date_from + 1)
Chris@0 346 g_height = 120
Chris@0 347 t_height = g_height + headers_heigth
Chris@0 348
Chris@0 349 y_start = pdf.GetY
Chris@0 350
Chris@0 351 # Months headers
Chris@0 352 month_f = gantt.date_from
Chris@0 353 left = subject_width
Chris@0 354 height = header_heigth
Chris@0 355 gantt.months.times do
Chris@0 356 width = ((month_f >> 1) - month_f) * zoom
Chris@0 357 pdf.SetY(y_start)
Chris@0 358 pdf.SetX(left)
Chris@0 359 pdf.Cell(width, height, "#{month_f.year}-#{month_f.month}", "LTR", 0, "C")
Chris@0 360 left = left + width
Chris@0 361 month_f = month_f >> 1
Chris@0 362 end
Chris@0 363
Chris@0 364 # Weeks headers
Chris@0 365 if show_weeks
Chris@0 366 left = subject_width
Chris@0 367 height = header_heigth
Chris@0 368 if gantt.date_from.cwday == 1
Chris@0 369 # gantt.date_from is monday
Chris@0 370 week_f = gantt.date_from
Chris@0 371 else
Chris@0 372 # find next monday after gantt.date_from
Chris@0 373 week_f = gantt.date_from + (7 - gantt.date_from.cwday + 1)
Chris@0 374 width = (7 - gantt.date_from.cwday + 1) * zoom-1
Chris@0 375 pdf.SetY(y_start + header_heigth)
Chris@0 376 pdf.SetX(left)
Chris@0 377 pdf.Cell(width + 1, height, "", "LTR")
Chris@0 378 left = left + width+1
Chris@0 379 end
Chris@0 380 while week_f <= gantt.date_to
Chris@0 381 width = (week_f + 6 <= gantt.date_to) ? 7 * zoom : (gantt.date_to - week_f + 1) * zoom
Chris@0 382 pdf.SetY(y_start + header_heigth)
Chris@0 383 pdf.SetX(left)
Chris@0 384 pdf.Cell(width, height, (width >= 5 ? week_f.cweek.to_s : ""), "LTR", 0, "C")
Chris@0 385 left = left + width
Chris@0 386 week_f = week_f+7
Chris@0 387 end
Chris@0 388 end
Chris@0 389
Chris@0 390 # Days headers
Chris@0 391 if show_days
Chris@0 392 left = subject_width
Chris@0 393 height = header_heigth
Chris@0 394 wday = gantt.date_from.cwday
Chris@0 395 pdf.SetFontStyle('B',7)
Chris@0 396 (gantt.date_to - gantt.date_from + 1).to_i.times do
Chris@0 397 width = zoom
Chris@0 398 pdf.SetY(y_start + 2 * header_heigth)
Chris@0 399 pdf.SetX(left)
Chris@0 400 pdf.Cell(width, height, day_name(wday).first, "LTR", 0, "C")
Chris@0 401 left = left + width
Chris@0 402 wday = wday + 1
Chris@0 403 wday = 1 if wday > 7
Chris@0 404 end
Chris@0 405 end
Chris@0 406
Chris@0 407 pdf.SetY(y_start)
Chris@0 408 pdf.SetX(15)
Chris@0 409 pdf.Cell(subject_width+g_width-15, headers_heigth, "", 1)
Chris@0 410
Chris@0 411 # Tasks
Chris@0 412 top = headers_heigth + y_start
Chris@0 413 pdf.SetFontStyle('B',7)
Chris@0 414 gantt.events.each do |i|
Chris@0 415 pdf.SetY(top)
Chris@0 416 pdf.SetX(15)
Chris@0 417
Chris@1 418 text = ""
Chris@0 419 if i.is_a? Issue
Chris@1 420 text = "#{i.tracker} #{i.id}: #{i.subject}"
Chris@0 421 else
Chris@1 422 text = i.name
Chris@0 423 end
Chris@1 424 text = "#{i.project} - #{text}" unless project && project == i.project
Chris@1 425 pdf.Cell(subject_width-15, 5, text, "LR")
Chris@0 426
Chris@1 427 pdf.SetY(top + 0.2)
Chris@0 428 pdf.SetX(subject_width)
Chris@1 429 pdf.SetFillColor(255, 255, 255)
Chris@1 430 pdf.Cell(g_width, 4.6, "", "LR", 0, "", 1)
Chris@0 431 pdf.SetY(top+1.5)
Chris@0 432
Chris@0 433 if i.is_a? Issue
Chris@0 434 i_start_date = (i.start_date >= gantt.date_from ? i.start_date : gantt.date_from )
Chris@0 435 i_end_date = (i.due_before <= gantt.date_to ? i.due_before : gantt.date_to )
Chris@0 436
Chris@0 437 i_done_date = i.start_date + ((i.due_before - i.start_date+1)*i.done_ratio/100).floor
Chris@0 438 i_done_date = (i_done_date <= gantt.date_from ? gantt.date_from : i_done_date )
Chris@0 439 i_done_date = (i_done_date >= gantt.date_to ? gantt.date_to : i_done_date )
Chris@0 440
Chris@0 441 i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
Chris@0 442
Chris@0 443 i_left = ((i_start_date - gantt.date_from)*zoom)
Chris@0 444 i_width = ((i_end_date - i_start_date + 1)*zoom)
Chris@0 445 d_width = ((i_done_date - i_start_date)*zoom)
Chris@0 446 l_width = ((i_late_date - i_start_date+1)*zoom) if i_late_date
Chris@0 447 l_width ||= 0
Chris@0 448
Chris@0 449 pdf.SetX(subject_width + i_left)
Chris@0 450 pdf.SetFillColor(200,200,200)
Chris@0 451 pdf.Cell(i_width, 2, "", 0, 0, "", 1)
Chris@0 452
Chris@0 453 if l_width > 0
Chris@0 454 pdf.SetY(top+1.5)
Chris@0 455 pdf.SetX(subject_width + i_left)
Chris@0 456 pdf.SetFillColor(255,100,100)
Chris@0 457 pdf.Cell(l_width, 2, "", 0, 0, "", 1)
Chris@0 458 end
Chris@0 459 if d_width > 0
Chris@0 460 pdf.SetY(top+1.5)
Chris@0 461 pdf.SetX(subject_width + i_left)
Chris@0 462 pdf.SetFillColor(100,100,255)
Chris@0 463 pdf.Cell(d_width, 2, "", 0, 0, "", 1)
Chris@0 464 end
Chris@0 465
Chris@0 466 pdf.SetY(top+1.5)
Chris@0 467 pdf.SetX(subject_width + i_left + i_width)
Chris@0 468 pdf.Cell(30, 2, "#{i.status} #{i.done_ratio}%")
Chris@0 469 else
Chris@0 470 i_left = ((i.start_date - gantt.date_from)*zoom)
Chris@0 471
Chris@0 472 pdf.SetX(subject_width + i_left)
Chris@0 473 pdf.SetFillColor(50,200,50)
Chris@0 474 pdf.Cell(2, 2, "", 0, 0, "", 1)
Chris@0 475
Chris@0 476 pdf.SetY(top+1.5)
Chris@0 477 pdf.SetX(subject_width + i_left + 3)
Chris@0 478 pdf.Cell(30, 2, "#{i.name}")
Chris@0 479 end
Chris@0 480
Chris@0 481 top = top + 5
Chris@0 482 pdf.SetDrawColor(200, 200, 200)
Chris@0 483 pdf.Line(15, top, subject_width+g_width, top)
Chris@0 484 if pdf.GetY() > 180
Chris@0 485 pdf.AddPage("L")
Chris@0 486 top = 20
Chris@0 487 pdf.Line(15, top, subject_width+g_width, top)
Chris@0 488 end
Chris@0 489 pdf.SetDrawColor(0, 0, 0)
Chris@0 490 end
Chris@0 491
Chris@0 492 pdf.Line(15, top, subject_width+g_width, top)
Chris@0 493 pdf.Output
Chris@0 494 end
Chris@0 495 end
Chris@0 496 end
Chris@0 497 end