如何用prawn更改整个表文本颜色

时间:2022-01-19 19:32:12

I have a RoR app that generates a pdf page using the prawn gem:

我有一个使用prawn gem生成pdf页面的RoR应用程序:

class ReportPdf < Prawn::Document
 def initialize(employees)
  super(top_margin: 70)
  @employees = employees
  list_employees
 end

 def list_employees
  move_down 20
  table list_employee_rows do
   row(0).font_style = :bold
   columns(1..4).align = :right
   self.row_colors = ["E8EDFF", "FFFFFF"]
   self.row(0).background_color = '005C89'
   self.row(0).text_color = "FFFFFF"
   self.header = true
  end
 end

 def list_employee_rows
  [["Name", "Badge number"]] +
  @employees.map do |employee|
   [employee.name, employee.badge_number]
  end
 end
end

I can change a specific row's text color (above I've changed the header's color to white) but how would I set the entire tables text color (and not the already set header's color)?

我可以更改特定行的文本颜色(上面我已经将标题的颜色更改为白色)但是如何设置整个表格的文本颜色(而不是已经设置的标题颜色)?

1 个解决方案

#1


0  

Inside the tables do block you should be able to define the properties of all the cells using a call to cells.style. There you will be able to define all the properties you like.

在表格内部阻止你应该能够使用对cells.style的调用来定义所有单元格的属性。在那里,您将能够定义您喜欢的所有属性。

#1


0  

Inside the tables do block you should be able to define the properties of all the cells using a call to cells.style. There you will be able to define all the properties you like.

在表格内部阻止你应该能够使用对cells.style的调用来定义所有单元格的属性。在那里,您将能够定义您喜欢的所有属性。