Project

General

Profile

Feature #3261 » pdf-image-r7810.diff

Toshi MARUYAMA, 2011-11-15 01:53

View differences:

lib/redmine/export/pdf.rb
MultiCell(w, h, fix_text_encoding(txt), border, align, fill, ln)
end
def RDMwriteHTMLCell(w, h, x, y, html='', border=0, ln=1, fill=0)
writeHTMLCell(w, h, x, y, fix_text_encoding(html), border, ln, fill)
def RDMwriteHTMLCell(w, h, x, y, txt='', attachments=[], border=0, ln=1, fill=0)
writeHTMLCell(w, h, x, y,
fix_text_encoding(
Redmine::WikiFormatting.to_html(Setting.text_formatting, txt)),
border, ln, fill)
end
def Footer
......
pdf.RDMCell(35+155, 5, l(:field_description), "LRT", 1)
pdf.SetFontStyle('',9)
pdf.RDMwriteHTMLCell(35+155, 5, 0, 0,
Redmine::WikiFormatting.to_html(
Setting.text_formatting, issue.description.to_s),"LRB")
issue.description.to_s, issue.attachments, "LRB")
# for CJK
truncate_length = ( l(:general_pdf_encoding).upcase == "UTF-8" ? 90 : 65 )
......
unless changeset.comments.blank?
pdf.SetFontStyle('',8)
pdf.RDMwriteHTMLCell(190,5,0,0,
Redmine::WikiFormatting.to_html(
Setting.text_formatting, changeset.comments.to_s), "")
changeset.comments.to_s, issue.attachments, "")
end
pdf.Ln
end
......
pdf.Ln unless journal.details.empty?
pdf.SetFontStyle('',8)
pdf.RDMwriteHTMLCell(190,5,0,0,
Redmine::WikiFormatting.to_html(
Setting.text_formatting, journal.notes.to_s), "")
journal.notes.to_s, issue.attachments, "")
end
pdf.Ln
end
......
pdf.SetImageScale(1.6)
pdf.SetFontStyle('',9)
pdf.RDMwriteHTMLCell(190,5,0,0,
Redmine::WikiFormatting.to_html(
Setting.text_formatting, page.content.text.to_s), "TLRB")
page.content.text.to_s, page.attachments, "TLRB")
if page.attachments.any?
pdf.Ln
pdf.SetFontStyle('B',9)
lib/redmine/export/pdf.rb
require 'fpdf/chinese'
require 'fpdf/japanese'
require 'fpdf/korean'
require 'core/rmagick'
module Redmine
module Export
......
attr_accessor :footer_date
def initialize(lang)
@@k_path_cache = Rails.root.join('tmp', 'pdf')
FileUtils.mkdir_p @@k_path_cache unless File::exist?(@@k_path_cache)
set_language_if_valid lang
pdf_encoding = l(:general_pdf_encoding).upcase
if RUBY_VERSION < '1.9'
lib/redmine/export/pdf.rb
end
def RDMwriteHTMLCell(w, h, x, y, txt='', attachments=[], border=0, ln=1, fill=0)
@attachments = attachments.sort_by(&:created_on).reverse
writeHTMLCell(w, h, x, y,
fix_text_encoding(
Redmine::WikiFormatting.to_html(Setting.text_formatting, txt)),
border, ln, fill)
end
def getImageFilename(attrname)
# attrname: general_pdf_encoding string file/uri name
attrname_utf8 = Redmine::CodesetUtil.to_utf8(attrname, l(:general_pdf_encoding))
if attrname_utf8 =~ /^[^\/"]+\.(gif|jpg|jpeg|png)$/i
@attachments.each do |attachment|
# attachment.filename : UTF-8 string name
# attachment.diskfile : real server path file name
#
# Japanese Shift_JIS and Traditional Chinese Big5
# are not compatible with ASCII.
# So, downcase needs for UTF-8.
if attachment.filename.downcase == attrname_utf8.downcase
if attachment.readable? && attachment.visible?
return attachment.diskfile
else
return nil
end
end
end
end
nil
end
def Footer
SetFont(@font_for_footer, 'I', 8)
SetY(-15)
lib/redmine/export/pdf.rb
pdf.SetFontStyle('B',9)
pdf.RDMCell(35+155, 5, l(:field_description), "LRT", 1)
pdf.SetFontStyle('',9)
# Set resize image scale
pdf.SetImageScale(1.6)
pdf.RDMwriteHTMLCell(35+155, 5, 0, 0,
issue.description.to_s, issue.attachments, "LRB")
lib/redmine/export/pdf.rb
end
end
end
return nil
else
# check of unsafe URI
if attrname_utf8 =~ /[^-_.!~*'()a-zA-Z\d;\/?:@&=+$,\[\]%]/n
return URI.encode(attrname_utf8)
else
return attrname_utf8
end
end
nil
end
def Footer
(9-9/10)