# HG changeset patch
# User Toshi MARUYAMA
# Date 1332216027 -32400
# Branch pdf-issue-10464-32
# Node ID b5ba7a4ed97862387034940f3f8add9f0acf3f40
# Parent 29e58ca43d8cbd0eba615eede715a9390cce20ee
pdf-issues-alignment

diff --git a/lib/redmine/export/pdf.rb b/lib/redmine/export/pdf.rb
--- a/lib/redmine/export/pdf.rb
+++ b/lib/redmine/export/pdf.rb
@@ -359,6 +359,10 @@ module Redmine
             end
           end
         end
+
+        # calculate columns alignment
+        @col_align = col_width.map {|x| x > table_width / (col_width.count + 1) ? 'L' : 'C'}
+
         col_width
       end
 
@@ -466,14 +470,16 @@ module Redmine
       # Renders MultiCells and returns the maximum height used
       def issues_to_pdf_write_cells(pdf, col_values, col_widths,
                                     row_height, head=false)
+        @col_align ||= []
         base_y = pdf.GetY
         max_height = row_height
         col_values.each_with_index do |column, i|
           col_x = pdf.GetX
           if head == true
-            pdf.RDMMultiCell(col_widths[i], row_height, column.caption, "T", 'L', 1)
+            pdf.RDMMultiCell(col_widths[i], row_height, column.caption, "T", 'C', 1)
           else
-            pdf.RDMMultiCell(col_widths[i], row_height, column, "T", 'L', 1)
+            @col_align[i] = 'L' if @col_align[i].nil?
+            pdf.RDMMultiCell(col_widths[i], row_height, column, "T", @col_align[i], 1)
           end
           max_height = (pdf.GetY - base_y) if (pdf.GetY - base_y) > max_height
           pdf.SetXY(col_x + col_widths[i], base_y);
