Patch #10869 » redmine-1.4.1-fullpdf.patch
| redmine/app/controllers/issues_controller.rb 2012-05-09 21:08:17.213716451 -0400 | ||
|---|---|---|
| 86 | 86 |
} |
| 87 | 87 |
format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
|
| 88 | 88 |
format.csv { send_data(issues_to_csv(@issues, @project, @query, params), :type => 'text/csv; header=present', :filename => 'export.csv') }
|
| 89 |
format.pdf { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'export.pdf') }
|
|
| 89 |
format.pdf { send_data(issues_to_pdf_dispatch(@issues, @project, @query), :type => 'application/pdf', :filename => 'export.pdf') }
|
|
| 90 | 90 |
end |
| 91 | 91 |
else |
| 92 | 92 |
respond_to do |format| |
| redmine/app/views/issues/index.html.erb 2012-05-09 22:14:42.338706985 -0400 | ||
|---|---|---|
| 63 | 63 |
<% other_formats_links do |f| %> |
| 64 | 64 |
<%= f.link_to 'Atom', :url => params.merge(:key => User.current.rss_key) %> |
| 65 | 65 |
<%= f.link_to 'CSV', :url => params, :onclick => "showModal('csv-export-options', '330px'); return false;" %>
|
| 66 |
<%= f.link_to 'PDF', :url => params %> |
|
| 66 |
<%= f.link_to 'PDF', :url => params.merge(:outputType => 'summary') %> |
|
| 67 |
<%= f.link_to_alias 'PDF', 'Full PDF', :url => params.merge(:outputType => 'full') %> |
|
| 67 | 68 |
<% end %> |
| 68 | 69 | |
| 69 | 70 |
<div id="csv-export-options" style="display:none;"> |
| redmine/lib/redmine/export/pdf.rb 2012-05-09 21:08:17.214702078 -0400 | ||
|---|---|---|
| 385 | 385 |
pdf.SetFillColor(255, 255, 255) |
| 386 | 386 |
end |
| 387 | 387 | |
| 388 |
def issues_to_pdf_dispatch(issues, project, query) |
|
| 389 |
# export_type is filled by view template thanks to spec_format_link_to |
|
| 390 |
(params['outputType'] == 'full') ? issues_to_pdf_full(issues, project, query) : issues_to_pdf(issues, project, query) |
|
| 391 |
end |
|
| 392 | ||
| 393 |
def issues_to_pdf_full(issues, project, query) |
|
| 394 |
pdf = ITCPDF.new(current_language) |
|
| 395 |
## pdf = IFPDF.new(current_language) |
|
| 396 | ||
| 397 |
title = query.new_record? ? l(:label_issue_plural) : query.name |
|
| 398 |
title = "#{project} - #{title}" if project
|
|
| 399 | ||
| 400 |
issues_to_pdf_header(pdf, title, issues, project, query) |
|
| 401 |
issues_to_pdf_content(pdf, title, issues, project, query) |
|
| 402 |
issues.each do |issue| |
|
| 403 |
issue_to_pdf_content(pdf, issue) |
|
| 404 |
end |
|
| 405 |
pdf.Output |
|
| 406 |
end |
|
| 407 | ||
| 408 | ||
| 388 | 409 |
# Returns a PDF string of a list of issues |
| 389 | 410 |
def issues_to_pdf(issues, project, query) |
| 390 | 411 |
pdf = ITCPDF.new(current_language) |
| 412 | ||
| 391 | 413 |
title = query.new_record? ? l(:label_issue_plural) : query.name |
| 392 | 414 |
title = "#{project} - #{title}" if project
|
| 415 | ||
| 416 |
issues_to_pdf_header(pdf, title, issues, project, query) |
|
| 417 |
issues_to_pdf_content(pdf, title, issues, project, query) |
|
| 418 |
pdf.Output |
|
| 419 |
end |
|
| 420 | ||
| 421 |
def issues_to_pdf_header(pdf, title, issues, project, query) |
|
| 393 | 422 |
pdf.SetTitle(title) |
| 394 | 423 |
pdf.alias_nb_pages |
| 395 | 424 |
pdf.footer_date = format_date(Date.today) |
| 396 | 425 |
pdf.SetAutoPageBreak(false) |
| 426 |
end |
|
| 427 | ||
| 428 | ||
| 429 |
def issues_to_pdf_content(pdf, title, issues, project, query) |
|
| 397 | 430 |
pdf.AddPage("L")
|
| 398 | 431 | |
| 399 | 432 |
# Landscape A4 = 210 x 297 mm |
| ... | ... | |
| 460 | 493 |
pdf.SetFontStyle('B',10)
|
| 461 | 494 |
pdf.RDMCell(0, row_height, '...') |
| 462 | 495 |
end |
| 463 |
pdf.Output |
|
| 464 | 496 |
end |
| 465 | 497 | |
| 466 | 498 |
# Renders MultiCells and returns the maximum height used |
| ... | ... | |
| 497 | 529 |
# Returns a PDF string of a single issue |
| 498 | 530 |
def issue_to_pdf(issue) |
| 499 | 531 |
pdf = ITCPDF.new(current_language) |
| 532 | ||
| 533 |
issue_to_pdf_header(pdf, issue) |
|
| 534 |
issue_to_pdf_content(pdf, issue) |
|
| 535 |
pdf.Output |
|
| 536 |
end |
|
| 537 | ||
| 538 |
def issue_to_pdf_header(pdf, issue) |
|
| 500 | 539 |
pdf.SetTitle("#{issue.project} - ##{issue.tracker} #{issue.id}")
|
| 501 | 540 |
pdf.alias_nb_pages |
| 502 | 541 |
pdf.footer_date = format_date(Date.today) |
| 542 |
end |
|
| 543 | ||
| 544 |
def issue_to_pdf_content(pdf,issue) |
|
| 503 | 545 |
pdf.AddPage |
| 504 | 546 |
pdf.SetFontStyle('B',11)
|
| 505 | 547 |
buf = "#{issue.project} - #{issue.tracker} # #{issue.id}"
|
| ... | ... | |
| 691 | 733 |
pdf.Ln |
| 692 | 734 |
end |
| 693 | 735 |
end |
| 694 |
pdf.Output |
|
| 695 | 736 |
end |
| 696 | 737 | |
| 697 | 738 |
# Returns a PDF string of a set of wiki pages |
| redmine/lib/redmine/views/other_formats_builder.rb 2012-05-09 22:05:15.210806887 -0400 | ||
|---|---|---|
| 28 | 28 |
html_options = { :class => name.to_s.downcase, :rel => 'nofollow' }.merge(options)
|
| 29 | 29 |
@view.content_tag('span', @view.link_to(caption, url, html_options))
|
| 30 | 30 |
end |
| 31 | ||
| 32 |
def link_to_alias(name, urlText, options={})
|
|
| 33 |
url = { :format => name.to_s.downcase }.merge(options.delete(:url) || {}).except('page')
|
|
| 34 |
# caption = options.delete(:caption) || name |
|
| 35 |
caption = urlText |
|
| 36 |
html_options = { :class => name.to_s.downcase, :rel => 'nofollow' }.merge(options)
|
|
| 37 |
@view.content_tag('span', @view.link_to(caption, url, html_options))
|
|
| 38 |
end |
|
| 31 | 39 |
end |
| 32 | 40 |
end |
| 33 | 41 |
end |