# encoding: utf-8 # # Redmine - project management software # Copyright (C) 2006-2009 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. require 'iconv' require 'rfpdf/fpdf' require 'rfpdf/chinese' module Redmine module Export module PDF include ActionView::Helpers::TextHelper include ActionView::Helpers::NumberHelper class IFPDF < FPDF include Redmine::I18n attr_accessor :footer_date def initialize(lang) super() set_language_if_valid lang case current_language.to_s.downcase when 'ko' extend(PDF_Korean) AddUHCFont() @font_for_content = 'UHC' @font_for_footer = 'UHC' when 'ja' extend(PDF_Japanese) AddSJISFont() @font_for_content = 'SJIS' @font_for_footer = 'SJIS' when 'zh' extend(PDF_Chinese) AddGBFont() @font_for_content = 'GB' @font_for_footer = 'GB' when 'zh-tw' extend(PDF_Chinese) AddBig5Font() @font_for_content = 'Big5' @font_for_footer = 'Big5' else @font_for_content = 'Arial' @font_for_footer = 'Helvetica' end SetCreator(Redmine::Info.app_name) SetFont(@font_for_content) end def SetFontStyle(style, size) SetFont(@font_for_content, style, size) end def SetTitle(txt) txt = begin utf16txt = Iconv.conv('UTF-16BE', 'UTF-8', txt) hextxt = "" rescue txt end || '' super(txt) end def textstring(s) # Format a text string if s =~ /^ [:user, :details], :order => "#{Journal.table_name}.created_on ASC") pdf.SetFontStyle('B',8) pdf.Cell(190,5, format_time(journal.created_on) + " - " + journal.user.name) pdf.Ln pdf.SetFontStyle('I',8) for detail in journal.details pdf.Cell(190,5, "- " + show_detail(detail, true)) pdf.Ln end if journal.notes? pdf.SetFontStyle('',8) pdf.MultiCell(190,5, journal.notes) end pdf.Ln end if issue.attachments.any? pdf.SetFontStyle('B',9) pdf.Cell(190,5, l(:label_attachment_plural), "B") pdf.Ln for attachment in issue.attachments pdf.SetFontStyle('',8) pdf.Cell(80,5, attachment.filename) pdf.Cell(20,5, number_to_human_size(attachment.filesize),0,0,"R") pdf.Cell(25,5, format_date(attachment.created_on),0,0,"R") pdf.Cell(65,5, attachment.author.name,0,0,"R") pdf.Ln end end pdf.Output end end end end