Merge pull request #4180 from ulferts/fix/slips_in_pdf_export

Fix/slips in pdf export
pull/4181/head
Oliver Günther 9 years ago
commit 7f73ca1b98
  1. 1
      app/models/work_package/pdf_export/ifpdf.rb
  2. 7
      app/models/work_package/pdf_export/to_pdf_helper.rb
  3. 15
      app/models/work_package/pdf_export/work_package_list_to_pdf.rb

@ -31,7 +31,6 @@ require 'rfpdf/fpdf'
class WorkPackage::PdfExport::IFPDF < FPDF
include Redmine::I18n
include Helpers
attr_accessor :footer_date
def initialize(lang)

@ -27,12 +27,15 @@
# See doc/COPYRIGHT.rdoc for more details.
#++
require 'work_package/pdf_export/ifpdf'
require 'work_package/pdf_export/itcpdf'
module WorkPackage::PdfExport::ToPdfHelper
def get_pdf(language)
if ['ko', 'ja', 'zh', 'zh-tw', 'th'].include? language.to_s.downcase
IFPDF.new(current_language)
::WorkPackage::PdfExport::IFPDF.new(current_language)
else
ITCPDF.new(current_language)
::WorkPackage::PdfExport::ITCPDF.new(current_language)
end
end
end

@ -85,12 +85,16 @@ class WorkPackage::PdfExport::WorkPackageListToPdf
# headers
pdf.SetFontStyle('B', 8)
pdf.SetFillColor(230, 230, 230)
base_x = pdf.get_x
base_y = pdf.get_y
column_contents = query.columns.map(&:caption)
max_height = calculate_max_height(column_contents, col_width)
pdf.RDMCell Page.table_width, max_height, '', 1, 1, 'L', 1
pdf.SetXY(base_x, base_y)
pdf.set_y(base_y)
write_cells(column_contents, col_width, Page.row_height)
draw_borders(base_x, base_y, base_y + max_height, col_width)
@ -131,7 +135,7 @@ class WorkPackage::PdfExport::WorkPackageListToPdf
s.to_s
}
max_height = calculate_max_height(column_contents, col_width)
max_height = calculate_max_height(col_values, col_width)
description_height = if options[:show_descriptions]
calculate_max_height([work_package.description.to_s],
[Page.table_width / 2])
@ -140,13 +144,14 @@ class WorkPackage::PdfExport::WorkPackageListToPdf
end
# make new page if it doesn't fit on the current one
space_left = Page.height - base_y - Page.bottom_margin
space_left = Page.height - pdf.get_y - Page.bottom_margin
if max_height + description_height > space_left
pdf.AddPage('L')
base_x = pdf.GetX
base_y = pdf.GetY
end
base_x = pdf.GetX
base_y = pdf.GetY
# write the cells on page
write_cells(col_values, col_width, Page.row_height)
draw_borders(base_x, base_y, base_y + max_height, col_width)

Loading…
Cancel
Save