##// END OF EJS Templates
revert r14907 (#19017)...
revert r14907 (#19017) r14907 breaks Arabic italic pdf rendering. git-svn-id: http://svn.redmine.org/redmine/trunk@14911 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r14529:12ede7d07f5e
r14529:12ede7d07f5e
Show More
pdf.rb
154 lines | 5.1 KiB | text/x-ruby | RubyLexer
Jean-Philippe Lang
Sets file encoding to utf-8 for ruby 1.9....
r2796 # encoding: utf-8
#
Jean-Philippe Lang
Move PDF stuff to a single helper....
r2224 # Redmine - project management software
Jean-Philippe Lang
Copyright update....
r13490 # Copyright (C) 2006-2015 Jean-Philippe Lang
Jean-Philippe Lang
Move PDF stuff to a single helper....
r2224 #
# 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.
Toshi MARUYAMA
remove trailing white-spaces lib/redmine/export/pdf.rb....
r5543 #
Jean-Philippe Lang
Move PDF stuff to a single helper....
r2224 # 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.
Toshi MARUYAMA
remove trailing white-spaces lib/redmine/export/pdf.rb....
r5543 #
Jean-Philippe Lang
Move PDF stuff to a single helper....
r2224 # 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.
Toshi MARUYAMA
use rbpdf gem instead of bundled rfpdf (#17570)...
r13004 require 'rbpdf'
Jean-Philippe Lang
Don't use Iconv with ruby1.9 (#12787)....
r10947
Jean-Philippe Lang
Move PDF stuff to a single helper....
r2224 module Redmine
module Export
module PDF
Toshi MARUYAMA
use rbpdf gem instead of bundled rfpdf (#17570)...
r13004 class ITCPDF < RBPDF
Toshi MARUYAMA
PDF: prepare switching TCPDF UTF-8 in non CJK or FPDF ANSI in CJK (#61)....
r5138 include Redmine::I18n
attr_accessor :footer_date
Toshi MARUYAMA
remove trailing white-spaces lib/redmine/export/pdf.rb....
r5543
Jean-Philippe Lang
Adds an option for displaying the issue description on the issue list (#3447)....
r10721 def initialize(lang, orientation='P')
Etienne Massip
File handling cleanup....
r9790 @@k_path_cache = Rails.root.join('tmp', 'pdf')
Toshi MARUYAMA
pdf: lib: prepare to use rfpdf plug-in rmagick feature (#3261)...
r7794 FileUtils.mkdir_p @@k_path_cache unless File::exist?(@@k_path_cache)
Toshi MARUYAMA
PDF: more strict Redmine TCPDF class initialize() (#8312)....
r5603 set_language_if_valid lang
Toshi MARUYAMA
use rbpdf gem instead of bundled rfpdf (#17570)...
r13004 super(orientation, 'mm', 'A4')
set_print_header(false)
set_rtl(l(:direction) == 'rtl')
Toshi MARUYAMA
pdf: define "general_pdf_fontname" at i18n yaml for multilingual environment (#13781)...
r13077 @font_for_content = l(:general_pdf_fontname)
Toshi MARUYAMA
pdf: use l(:general_pdf_monospaced_fontname) (#19017)...
r14528 @monospaced_font_for_content = l(:general_pdf_monospaced_fontname)
Toshi MARUYAMA
pdf: define "general_pdf_fontname" at i18n yaml for multilingual environment (#13781)...
r13077 @font_for_footer = l(:general_pdf_fontname)
Toshi MARUYAMA
use rbpdf gem instead of bundled rfpdf (#17570)...
r13004 set_creator(Redmine::Info.app_name)
set_font(@font_for_content)
Toshi MARUYAMA
remove trailing white-spaces lib/redmine/export/pdf.rb....
r5543
Toshi MARUYAMA
use rbpdf gem instead of bundled rfpdf (#17570)...
r13004 set_header_font([@font_for_content, '', 10])
set_footer_font([@font_for_content, '', 8])
Toshi MARUYAMA
pdf: use l(:general_pdf_monospaced_fontname) (#19017)...
r14528 set_default_monospaced_font(@monospaced_font_for_content)
Jean-Philippe Lang
Change default display mode for PDF Export to OneColumn (#19546)....
r13917 set_display_mode('default', 'OneColumn')
Toshi MARUYAMA
PDF: prepare switching TCPDF UTF-8 in non CJK or FPDF ANSI in CJK (#61)....
r5138 end
Toshi MARUYAMA
remove trailing white-spaces lib/redmine/export/pdf.rb....
r5543
Toshi MARUYAMA
use rbpdf gem instead of bundled rfpdf (#17570)...
r13004 def SetFontStyle(style, size)
set_font(@font_for_content, style, size)
Toshi MARUYAMA
PDF: prepare switching TCPDF UTF-8 in non CJK or FPDF ANSI in CJK (#61)....
r5138 end
Toshi MARUYAMA
remove trailing white-spaces lib/redmine/export/pdf.rb....
r5543
Toshi MARUYAMA
pdf: remove styles of Arabic/Persian Italic and Thai Bold (#10681, #18586)...
r13594 def SetFont(family, style='', size=0, fontfile='')
Toshi MARUYAMA
pdf: remove styles by fontname instated of Arabic/Persian/Thai locale (#10681, #18586)...
r13595 # FreeSerif Bold Thai font has problem.
Toshi MARUYAMA
revert r14907 (#19017)...
r14529 style.delete!('B') if l(:general_pdf_fontname) == 'freeserif'
Toshi MARUYAMA
pdf: remove styles by fontname instated of Arabic/Persian/Thai locale (#10681, #18586)...
r13595 # DejaVuSans Italic Arabic and Persian font has problem.
Toshi MARUYAMA
revert r14907 (#19017)...
r14529 style.delete!('I') if l(:general_pdf_fontname) == 'DejaVuSans' && current_language.to_s.casecmp("vi") != 0
Toshi MARUYAMA
pdf: remove styles of Arabic/Persian Italic and Thai Bold (#10681, #18586)...
r13594 super(family, style, size, fontfile)
end
alias_method :set_font, :SetFont
Toshi MARUYAMA
PDF: replace invalid UTF-8 sequences in TCPDF (#61, #8312)....
r5596 def fix_text_encoding(txt)
Toshi MARUYAMA
remove general_pdf_encoding from lib/redmine/export/pdf.rb (#17570)...
r13005 RDMPdfEncoding::rdm_from_utf8(txt, "UTF-8")
Toshi MARUYAMA
PDF: replace invalid UTF-8 sequences in TCPDF (#61, #8312)....
r5596 end
Jean-Philippe Lang
Strip {{toc}} tags in pdf exports (#9842)....
r10997 def formatted_text(text)
Jean-Philippe Lang
Adds support for macro and Redmine links in PDF export (#13051)....
r13562 Redmine::WikiFormatting.to_html(Setting.text_formatting, text)
Jean-Philippe Lang
Strip {{toc}} tags in pdf exports (#9842)....
r10997 end
Toshi MARUYAMA
PDF: code clean up lib/redmine/export/pdf.rb....
r6018 def RDMCell(w ,h=0, txt='', border=0, ln=0, align='', fill=0, link='')
Toshi MARUYAMA
use rbpdf gem instead of bundled rfpdf (#17570)...
r13004 cell(w, h, txt, border, ln, align, fill, link)
Toshi MARUYAMA
PDF: replace invalid UTF-8 sequences in TCPDF (#61, #8312)....
r5596 end
Toshi MARUYAMA
PDF: add 'ln' parameter for drawing lines at RDMMultiCell() (#69)....
r6015 def RDMMultiCell(w, h=0, txt='', border=0, align='', fill=0, ln=1)
Toshi MARUYAMA
use rbpdf gem instead of bundled rfpdf (#17570)...
r13004 multi_cell(w, h, txt, border, align, fill, ln)
Toshi MARUYAMA
PDF: replace invalid UTF-8 sequences in TCPDF (#61, #8312)....
r5596 end
Toshi MARUYAMA
remove trailing white-spaces lib/redmine/export/pdf.rb....
r5543
Jean-Philippe Lang
Adds support for macro and Redmine links in PDF export (#13051)....
r13562 def RDMwriteFormattedCell(w, h, x, y, txt='', attachments=[], border=0, ln=1, fill=0)
Toshi MARUYAMA
pdf: add the new feature to include attachment images (#3261)...
r7795 @attachments = attachments
Toshi MARUYAMA
use rbpdf gem instead of bundled rfpdf (#17570)...
r13004
css_tag = ' <style>
table, td {
border: 2px #ff0000 solid;
}
th { background-color:#EEEEEE; padding: 4px; white-space:nowrap; text-align: center; font-style: bold;}
pre {
background-color: #fafafa;
}
</style>'
Jean-Philippe Lang
Adds support for macro and Redmine links in PDF export (#13051)....
r13562 # Strip {{toc}} tags
txt.gsub!(/<p>\{\{([<>]?)toc\}\}<\/p>/i, '')
writeHTMLCell(w, h, x, y, css_tag + txt, border, ln, fill)
end
def RDMwriteHTMLCell(w, h, x, y, txt='', attachments=[], border=0, ln=1, fill=0)
txt = formatted_text(txt)
RDMwriteFormattedCell(w, h, x, y, txt, attachments, border, ln, fill)
Toshi MARUYAMA
PDF: add new "RDMwriteHTMLCell" method for textilized PDF (#69)....
r6017 end
Toshi MARUYAMA
use rbpdf gem instead of bundled rfpdf (#17570)...
r13004 def get_image_filename(attrname)
atta = RDMPdfEncoding.attach(@attachments, attrname, "UTF-8")
Toshi MARUYAMA
pdf: add the new feature to include attachment images (#3261)...
r7795 if atta
return atta.diskfile
else
return nil
end
end
Toshi MARUYAMA
use rbpdf gem instead of bundled rfpdf (#17570)...
r13004 def get_sever_url(url)
if !empty_string(url) and (url[0, 1] == '/')
Setting.host_name.split('/')[0] + url
else
url
Jean-Philippe Lang
Adds bookmarks to PDF when exporting a grouped issue list....
r8612 end
end
Toshi MARUYAMA
use rbpdf gem instead of bundled rfpdf (#17570)...
r13004 def Footer
set_font(@font_for_footer, 'I', 8)
set_x(15)
if get_rtl
RDMCell(0, 5, @footer_date, 0, 0, 'R')
else
RDMCell(0, 5, @footer_date, 0, 0, 'L')
Jean-Philippe Lang
Adds bookmarks to PDF when exporting a grouped issue list....
r8612 end
Toshi MARUYAMA
use rbpdf gem instead of bundled rfpdf (#17570)...
r13004 set_x(-30)
RDMCell(0, 5, get_alias_num_page() + '/' + get_alias_nb_pages(), 0, 0, 'C')
Jean-Philippe Lang
Adds bookmarks to PDF when exporting a grouped issue list....
r8612 end
Toshi MARUYAMA
PDF: prepare switching TCPDF UTF-8 in non CJK or FPDF ANSI in CJK (#61)....
r5138 end
Toshi MARUYAMA
PDF: move fix_text_encoding() logic to new method for common use in FPDF and TCPDF (#61, #8312)....
r5593 class RDMPdfEncoding
Toshi MARUYAMA
move iconv from utf8 logic from pdf to lib/redmine/codeset_util.rb for common use (#8549)...
r7698 def self.rdm_from_utf8(txt, encoding)
Toshi MARUYAMA
PDF: move fix_text_encoding() logic to new method for common use in FPDF and TCPDF (#61, #8312)....
r5593 txt ||= ''
Toshi MARUYAMA
move iconv from utf8 logic from pdf to lib/redmine/codeset_util.rb for common use (#8549)...
r7698 txt = Redmine::CodesetUtil.from_utf8(txt, encoding)
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 txt.force_encoding('ASCII-8BIT')
Toshi MARUYAMA
PDF: move fix_text_encoding() logic to new method for common use in FPDF and TCPDF (#61, #8312)....
r5593 txt
end
Toshi MARUYAMA
pdf: lib: add the method to return attachment from filename and encoding (#3261)...
r7792
def self.attach(attachments, filename, encoding)
filename_utf8 = Redmine::CodesetUtil.to_utf8(filename, encoding)
atta = nil
if filename_utf8 =~ /^[^\/"]+\.(gif|jpg|jpe|jpeg|png)$/i
atta = Attachment.latest_attach(attachments, filename_utf8)
end
if atta && atta.readable? && atta.visible?
return atta
else
return nil
end
end
Toshi MARUYAMA
PDF: move fix_text_encoding() logic to new method for common use in FPDF and TCPDF (#61, #8312)....
r5593 end
Jean-Philippe Lang
Move PDF stuff to a single helper....
r2224 end
end
end