Defect #61 » prawn.patch
| app/helpers/pdf_helper.rb (wersja 0) | ||
|---|---|---|
|
# redMine - project management software
|
||
|
# Copyright (C) 2006 Jean-Philippe Lang
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License
|
||
|
# as published by the Free Software Foundation; either version 2
|
||
|
# of the License, or (at your option) any later version.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program; if not, write to the Free Software
|
||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
module PdfHelper
|
||
|
def PdfHelper.font_for_lang(lang)
|
||
|
case lang.to_s
|
||
|
when 'ja'
|
||
|
return "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf"
|
||
|
when 'zh'
|
||
|
return "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf"
|
||
|
when 'zh-tw'
|
||
|
return "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf"
|
||
|
else
|
||
|
return "#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf"
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| app/controllers/issues_controller.rb (kopia robocza) | ||
|---|---|---|
|
format.html { render :template => 'issues/index.rhtml', :layout => !request.xhr? }
|
||
|
format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
|
||
|
format.csv { send_data(issues_to_csv(@issues, @project).read, :type => 'text/csv; header=present', :filename => 'export.csv') }
|
||
|
format.pdf { send_data(issues_to_pdf(@issues, @project), :type => 'application/pdf', :filename => 'export.pdf') }
|
||
|
format.pdf { send_data(render(:template => 'issues/index.pdf.prawn', :layout => false), :type => 'application/pdf', :filename => 'export.pdf') }
|
||
|
end
|
||
|
else
|
||
|
# Send html if the query is not valid
|
||
| app/views/issues/index.pdf.prawn (wersja 0) | ||
|---|---|---|
|
Prawn::Document.generate('index.pdf', :page_layout => :landscape) do |pdf|
|
||
|
pdf.font(PdfHelper.font_for_lang(current_language))
|
||
|
title = @project ? "#{@project.name} - #{l(:label_issue_plural)}" : "#{l(:label_issue_plural)}"
|
||
|
pdf.header pdf.margin_box.top_left do
|
||
|
pdf.text title , :size => 12, :align => :left
|
||
|
pdf.stroke_horizontal_rule
|
||
|
end
|
||
|
pdf.footer [pdf.margin_box.left, pdf.margin_box.bottom + 20] do
|
||
|
pdf.stroke_horizontal_rule
|
||
|
pdf.text format_date(Date.today), :size => 12
|
||
|
end
|
||
|
pdf.move_down 25
|
||
|
#rows
|
||
|
rows=[]
|
||
|
i=0
|
||
|
@issues.each do |issue|
|
||
|
rows[i] = [issue.id.to_s, issue.tracker.name, issue.status.name,
|
||
|
issue.priority.name, issue.assigned_to ? issue.assigned_to.name : '',
|
||
|
format_date(issue.updated_on),
|
||
|
@project == issue.project ? issue.subject : "#{issue.project.name} - #{issue.subject}"]
|
||
|
i=i+1
|
||
|
end
|
||
|
pdf.table rows,
|
||
|
:font_size => 11,
|
||
|
:horizontal_padding => 10,
|
||
|
:vertical_padding => 3,
|
||
|
:border_width => 1,
|
||
|
:position => :left,
|
||
|
:headers => ["#", l(:field_tracker), l(:field_status), l(:field_priority), l(:field_assigned_to), l(:field_updated_on), l(:field_subject)],
|
||
|
:align => {0 => :center},
|
||
|
:align_headers => :left,
|
||
|
:widths => {6 => 250},
|
||
|
:row_colors => ["ffffff","cccccc"]
|
||
|
|
||
|
end
|
||