Index: app/helpers/pdf_helper.rb =================================================================== --- app/helpers/pdf_helper.rb (wersja 0) +++ app/helpers/pdf_helper.rb (wersja 0) @@ -0,0 +1,31 @@ +# 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 'ko' + return "#{Prawn::BASEDIR}/data/fonts/UnBatang.ttf" + 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 Index: app/controllers/issues_controller.rb =================================================================== --- app/controllers/issues_controller.rb (wersja 2056) +++ app/controllers/issues_controller.rb (kopia robocza) @@ -67,7 +67,7 @@ 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(render(:template => 'issues/index.rfpdf', :layout => false), :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 Index: app/views/issues/index.pdf.prawn =================================================================== --- app/views/issues/index.pdf.prawn (wersja 0) +++ app/views/issues/index.pdf.prawn (wersja 0) @@ -0,0 +1,41 @@ +Prawn::Document.new(: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