Project

General

Profile

Patch #8295 » wrap_title_fields_in_pdf_r5647.patch

Jun NAITOH, 2011-05-05 06:07

View differences:

lib/redmine/export/pdf.rb (working copy)
228 228
        # headers
229 229
        pdf.SetFontStyle('B',8)
230 230
        pdf.SetFillColor(230, 230, 230)
231
        pdf.RDMCell(col_id_width, row_height, "#", 1, 0, 'C', 1)
232
        query.columns.each_with_index do |column, i|
233
          pdf.RDMCell(col_width[i], row_height, column.caption, 1, 0, 'L', 1)
234
        end
235
        pdf.Ln
231

  
232
        # render it background to find the max height used
233
        base_x = pdf.GetX
234
        base_y = pdf.GetY
235
        max_height = issues_to_pdf_write_cells(pdf, query.columns, col_width, row_height, true)
236
        pdf.Rect(base_x, base_y, table_width, max_height, 'FD');
237
        pdf.SetXY(base_x, base_y);
238

  
239
        # write the cells on page
240
        pdf.RDMCell(col_id_width, row_height, "#", "T", 0, 'C', 1)
241
        issues_to_pdf_write_cells(pdf, query.columns, col_width, row_height, true)
242
        issues_to_pdf_draw_borders(pdf, base_x, base_y, base_y + max_height, col_id_width, col_width)
243
        pdf.SetY(base_y + max_height);
236 244
        
237 245
        # rows
238 246
        pdf.SetFontStyle('',8)
......
296 304
      end
297 305
      
298 306
      # Renders MultiCells and returns the maximum height used
299
      def issues_to_pdf_write_cells(pdf, col_values, col_widths, row_height)
307
      def issues_to_pdf_write_cells(pdf, col_values, col_widths, row_height, head=false)
300 308
        base_y = pdf.GetY
301 309
        max_height = row_height
302 310
        col_values.each_with_index do |column, i|
303 311
          col_x = pdf.GetX
304
          pdf.RDMMultiCell(col_widths[i], row_height, col_values[i], "T", 'L', 1)
312
          if head == true
313
            pdf.RDMMultiCell(col_widths[i], row_height, column.caption, "T", 'L', 1)
314
          else
315
            pdf.RDMMultiCell(col_widths[i], row_height, column, "T", 'L', 1)
316
          end
305 317
          max_height = (pdf.GetY - base_y) if (pdf.GetY - base_y) > max_height
306 318
          pdf.SetXY(col_x + col_widths[i], base_y);
307 319
        end
(1-1/3)