# 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 'fpdf/chinese' require 'fpdf/japanese' require 'fpdf/korean' module Redmine module Export module PDF include ActionView::Helpers::TextHelper include ActionView::Helpers::NumberHelper class ITCPDF < TCPDF include Redmine::I18n attr_accessor :footer_date def initialize(lang) super() set_language_if_valid lang @font_for_content = 'FreeSans' @font_for_footer = 'FreeSans' 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 =~ /^" 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.RDMCell(190,5, format_time(journal.created_on) + " - " + journal.user.name) pdf.Ln pdf.SetFontStyle('I',8) for detail in journal.details pdf.RDMCell(190,5, "- " + show_detail(detail, true)) pdf.Ln end if journal.notes? pdf.SetFontStyle('',8) pdf.RDMMultiCell(190,5, journal.notes.to_s) end pdf.Ln end if issue.attachments.any? pdf.SetFontStyle('B',9) pdf.RDMCell(190,5, l(:label_attachment_plural), "B") pdf.Ln for attachment in issue.attachments pdf.SetFontStyle('',8) pdf.RDMCell(80,5, attachment.filename) pdf.RDMCell(20,5, number_to_human_size(attachment.filesize),0,0,"R") pdf.RDMCell(25,5, format_date(attachment.created_on),0,0,"R") pdf.RDMCell(65,5, attachment.author.name,0,0,"R") pdf.Ln end end pdf.Output end end end end