summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-01-30 18:42:14 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-01-30 18:42:14 +0000
commit3d27bf5318ef22d5d66e1863a62c3c6c1f203d66 (patch)
tree41da619407d5a38bd1538434597fc34fdb23d310 /lib
parenta03c585a84d3197e0c35617dc78c9e3ca264c56a (diff)
downloadredmine-3d27bf5318ef22d5d66e1863a62c3c6c1f203d66.tar.gz
redmine-3d27bf5318ef22d5d66e1863a62c3c6c1f203d66.zip
Adds export of all wiki pages to a PDF file (#3463).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8734 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r--lib/redmine/export/pdf.rb40
1 files changed, 38 insertions, 2 deletions
diff --git a/lib/redmine/export/pdf.rb b/lib/redmine/export/pdf.rb
index f59ff5461..75bf8e863 100644
--- a/lib/redmine/export/pdf.rb
+++ b/lib/redmine/export/pdf.rb
@@ -573,8 +573,25 @@ module Redmine
pdf.Output
end
+ # Returns a PDF string of a set of wiki pages
+ def wiki_pages_to_pdf(pages, project)
+ pdf = ITCPDF.new(current_language)
+ pdf.SetTitle(project.name)
+ pdf.alias_nb_pages
+ pdf.footer_date = format_date(Date.today)
+ pdf.AddPage
+ pdf.SetFontStyle('B',11)
+ pdf.RDMMultiCell(190,5, project.name)
+ pdf.Ln
+ # Set resize image scale
+ pdf.SetImageScale(1.6)
+ pdf.SetFontStyle('',9)
+ write_page_hierarchy(pdf, pages.group_by(&:parent_id))
+ pdf.Output
+ end
+
# Returns a PDF string of a single wiki page
- def wiki_to_pdf(page, project)
+ def wiki_page_to_pdf(page, project)
pdf = ITCPDF.new(current_language)
pdf.SetTitle("#{project} - #{page.title}")
pdf.alias_nb_pages
@@ -587,6 +604,26 @@ module Redmine
# Set resize image scale
pdf.SetImageScale(1.6)
pdf.SetFontStyle('',9)
+ write_wiki_page(pdf, page)
+ pdf.Output
+ end
+
+ def write_page_hierarchy(pdf, pages, node=nil, level=0)
+ if pages[node]
+ pages[node].each do |page|
+ if @new_page
+ pdf.AddPage
+ else
+ @new_page = true
+ end
+ pdf.Bookmark page.title, level
+ write_wiki_page(pdf, page)
+ write_page_hierarchy(pdf, pages, page.id, level + 1) if pages[page.id]
+ end
+ end
+ end
+
+ def write_wiki_page(pdf, page)
pdf.RDMwriteHTMLCell(190,5,0,0,
page.content.text.to_s, page.attachments, "TLRB")
if page.attachments.any?
@@ -603,7 +640,6 @@ module Redmine
pdf.Ln
end
end
- pdf.Output
end
class RDMPdfEncoding