--- a/lib/redmine/export/pdf.rb 2011-03-08 04:44:40.000000000 +0900 +++ b/lib/redmine/export/pdf.rb 2011-03-29 22:16:24.000000000 +0900 @@ -19,7 +19,9 @@ require 'iconv' require 'rfpdf/fpdf' -require 'rfpdf/chinese' +require 'fpdf/chinese' +require 'fpdf/japanese' +require 'fpdf/korean' module Redmine module Export @@ -27,6 +29,58 @@ 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 =~ /^ [: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.UTF8Cell(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.UTF8Cell(190,5, "- " + show_detail(detail, true)) pdf.Ln end if journal.notes? pdf.SetFontStyle('',8) - pdf.MultiCell(190,5, journal.notes.to_s) + pdf.UTF8MultiCell(190,5, journal.notes.to_s) end pdf.Ln end if issue.attachments.any? pdf.SetFontStyle('B',9) - pdf.Cell(190,5, l(:label_attachment_plural), "B") + pdf.UTF8Cell(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.UTF8Cell(80,5, attachment.filename) + pdf.UTF8Cell(20,5, number_to_human_size(attachment.filesize),0,0,"R") + pdf.UTF8Cell(25,5, format_date(attachment.created_on),0,0,"R") + pdf.UTF8Cell(65,5, attachment.author.name,0,0,"R") pdf.Ln end end