diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-11-06 10:48:28 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-11-06 10:48:28 +0000 |
commit | 1713432ab0090eb285f008a09a57ae66d2f84dc5 (patch) | |
tree | 65fcb48cabe0198ccc5675a2149fe2f8a63db670 /lib | |
parent | 0921042bc461a1242ceee8c35462133e093a51e0 (diff) | |
download | redmine-1713432ab0090eb285f008a09a57ae66d2f84dc5.tar.gz redmine-1713432ab0090eb285f008a09a57ae66d2f84dc5.zip |
pdf: lib: add a method to export wiki (#401)
Contributed by Jun NAITOH.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7740 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r-- | lib/redmine/export/pdf.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/redmine/export/pdf.rb b/lib/redmine/export/pdf.rb index dcce2ef96..03b137a5b 100644 --- a/lib/redmine/export/pdf.rb +++ b/lib/redmine/export/pdf.rb @@ -410,6 +410,40 @@ module Redmine pdf.Output end + # Returns a PDF string of a single wiki page + def wiki_to_pdf(page, project) + pdf = ITCPDF.new(current_language) + pdf.SetTitle("#{project} - #{page.title}") + pdf.alias_nb_pages + pdf.footer_date = format_date(Date.today) + pdf.AddPage + pdf.SetFontStyle('B',11) + pdf.RDMMultiCell(190,5, + "#{project} - #{page.title} - # #{page.content.version}") + pdf.Ln + # Set resize image scale + 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") + if page.attachments.any? + pdf.Ln + pdf.SetFontStyle('B',9) + pdf.RDMCell(190,5, l(:label_attachment_plural), "B") + pdf.Ln + for attachment in page.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 + class RDMPdfEncoding include Redmine::I18n def self.rdm_pdf_iconv(ic, txt) |