From 325af8d48cca75ada9a765ca2affac97d90791ea Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Wed, 30 Mar 2011 11:32:35 +0000 Subject: [PATCH] PDF: switch TCPDF UTF-8 or FPDF ANSI (#61). If server is Windows or language is CJK or Thai, Redmine uses FPDF. Else Redmine uses TCPDF. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5259 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/export/pdf.rb | 29 +++++++++++++++++++++++------ lib/redmine/helpers/gantt.rb | 11 ++++++++++- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/lib/redmine/export/pdf.rb b/lib/redmine/export/pdf.rb index d1c890959..d6f247ecb 100644 --- a/lib/redmine/export/pdf.rb +++ b/lib/redmine/export/pdf.rb @@ -37,7 +37,7 @@ module Redmine super() set_language_if_valid lang @font_for_content = 'FreeSans' - @font_for_footer = 'FreeSans' + @font_for_footer = 'FreeSans' SetCreator(Redmine::Info.app_name) SetFont(@font_for_content) end @@ -93,7 +93,7 @@ module Redmine extend(PDF_Korean) AddUHCFont() @font_for_content = 'UHC' - @font_for_footer = 'UHC' + @font_for_footer = 'UHC' when 'ja' extend(PDF_Japanese) AddSJISFont() @@ -111,7 +111,7 @@ module Redmine @font_for_footer = 'Big5' else @font_for_content = 'Arial' - @font_for_footer = 'Helvetica' + @font_for_footer = 'Helvetica' end SetCreator(Redmine::Info.app_name) SetFont(@font_for_content) @@ -179,8 +179,16 @@ module Redmine # Returns a PDF string of a list of issues def issues_to_pdf(issues, project, query) - pdf = IFPDF.new(current_language) - + if Redmine::Platform.mswin? || + ( current_language.to_s.downcase == 'ko' || + current_language.to_s.downcase == 'ja' || + current_language.to_s.downcase == 'zh' || + current_language.to_s.downcase == 'zh-tw' || + current_language.to_s.downcase == 'th' ) + pdf = IFPDF.new(current_language) + else + pdf = ITCPDF.new(current_language) + end title = query.new_record? ? l(:label_issue_plural) : query.name title = "#{project} - #{title}" if project pdf.SetTitle(title) @@ -251,7 +259,16 @@ module Redmine # Returns a PDF string of a single issue def issue_to_pdf(issue) - pdf = IFPDF.new(current_language) + if Redmine::Platform.mswin? || + ( current_language.to_s.downcase == 'ko' || + current_language.to_s.downcase == 'ja' || + current_language.to_s.downcase == 'zh' || + current_language.to_s.downcase == 'zh-tw' || + current_language.to_s.downcase == 'th' ) + pdf = IFPDF.new(current_language) + else + pdf = ITCPDF.new(current_language) + end pdf.SetTitle("#{issue.project} - ##{issue.tracker} #{issue.id}") pdf.alias_nb_pages pdf.footer_date = format_date(Date.today) diff --git a/lib/redmine/helpers/gantt.rb b/lib/redmine/helpers/gantt.rb index 1413e6f91..8a03af0f7 100644 --- a/lib/redmine/helpers/gantt.rb +++ b/lib/redmine/helpers/gantt.rb @@ -507,7 +507,16 @@ module Redmine end if Object.const_defined?(:Magick) def to_pdf - pdf = ::Redmine::Export::PDF::IFPDF.new(current_language) + if Redmine::Platform.mswin? || + ( current_language.to_s.downcase == 'ko' || + current_language.to_s.downcase == 'ja' || + current_language.to_s.downcase == 'zh' || + current_language.to_s.downcase == 'zh-tw' || + current_language.to_s.downcase == 'th' ) + pdf = ::Redmine::Export::PDF::IFPDF.new(current_language) + else + pdf = ::Redmine::Export::PDF::ITCPDF.new(current_language) + end pdf.SetTitle("#{l(:label_gantt)} #{project}") pdf.alias_nb_pages pdf.footer_date = format_date(Date.today) -- 2.39.5