prawn-table set header's row background color

Andrey Deineko
pdf.table([header, row1, row2], width: 490, cell_style: { size: 7, align: :center }) do
  style(row(0), padding: [4,2], font: "#{Prawn::BASEDIR}/data/fonts/DejaVuSans-Bold.ttf")
  # style(row(0).columns(2..3), width: 10 )
  # style(row(0), cell_style: {background_color: "#f5f5dc"} )
  style(row(1), padding: [16,10])
  style(row(1).columns(-2..-1), align: :right)
  style(row(2).column(0), borders: [])
  style(row(2).column(-2..-1), padding: [6,10], align: :right)
end

I want row(0) to have a background color, but can't find out how (see the commented out lines - those are not working).

I use prawn-rails and prawn-table gems.

Thanks!

Andrey Deineko

Ok.. I am too quick with asking questions.

Here is how you do that (use row_colors option):

pdf.table([header, row1, row2], width: 490, cell_style: { size: 7, align: :center}, row_colors: ['F0F0A3', nil, nil]) do
  style(row(0), padding: [4,2], font: "#{Prawn::BASEDIR}/data/fonts/DejaVuSans-Bold.ttf")
  style(row(1), padding: [16,10])
  style(row(1).columns(-2..-1), align: :right)
  style(row(2).column(0), borders: [])
  style(row(2).column(-2..-1), padding: [6,10], align: :right)
end

I don't think, it is the best way to achieve the header's background color, but what I did is just set the colors for each row (actually color for the first row, and nil for each left).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Changing the background color of a pdf with Prawn?

From Dev

How to set minimum height of row in prawn Table cell

From Dev

Animating the background color of an HTML table's cell (or the whole row) on an event

From Dev

How can I get the background color of an HTML table's row?

From Dev

Setting background color of a table row

From Dev

Set table row background colour of td's with a specific value

From Java

how to set header background color in ionic 4

From Dev

Change background color of table cells according to their header

From Dev

Angular material table header background color change

From Dev

vertical headings table - header and row same color

From Dev

DatGridView Header Cell's Background Color

From Dev

DatGridView Header Cell's Background Color

From Java

How to set the background color of a Row() in Flutter?

From Dev

How to set the background color for specified row in datagridview?

From Dev

Set background color for particular row of JTable at runtime

From Dev

How to set the color of a horizontal line in Prawn?

From Dev

Table row Background Color not showing when printing

From Dev

Watchkit Table Row Background Color programatically

From Dev

Change dynamically generated table row background color

From Dev

Change background color of a table row on click

From Dev

Change dynamically generated table row background color

From Dev

Watchkit Table Row Background Color programatically

From Dev

Background color for the last second row of the table

From Dev

set background color for specific cell in markdown table

From Dev

How to Set the Background Color of a Cell in a MigraDoc Table

From Dev

Set Background Color of a clicked table cell

From Dev

XSLT set table background color when

From Dev

Add Background Color to Listview's Specific Row

From Dev

How to set alternative row color and background color of jqgrid

Related Related

  1. 1

    Changing the background color of a pdf with Prawn?

  2. 2

    How to set minimum height of row in prawn Table cell

  3. 3

    Animating the background color of an HTML table's cell (or the whole row) on an event

  4. 4

    How can I get the background color of an HTML table's row?

  5. 5

    Setting background color of a table row

  6. 6

    Set table row background colour of td's with a specific value

  7. 7

    how to set header background color in ionic 4

  8. 8

    Change background color of table cells according to their header

  9. 9

    Angular material table header background color change

  10. 10

    vertical headings table - header and row same color

  11. 11

    DatGridView Header Cell's Background Color

  12. 12

    DatGridView Header Cell's Background Color

  13. 13

    How to set the background color of a Row() in Flutter?

  14. 14

    How to set the background color for specified row in datagridview?

  15. 15

    Set background color for particular row of JTable at runtime

  16. 16

    How to set the color of a horizontal line in Prawn?

  17. 17

    Table row Background Color not showing when printing

  18. 18

    Watchkit Table Row Background Color programatically

  19. 19

    Change dynamically generated table row background color

  20. 20

    Change background color of a table row on click

  21. 21

    Change dynamically generated table row background color

  22. 22

    Watchkit Table Row Background Color programatically

  23. 23

    Background color for the last second row of the table

  24. 24

    set background color for specific cell in markdown table

  25. 25

    How to Set the Background Color of a Cell in a MigraDoc Table

  26. 26

    Set Background Color of a clicked table cell

  27. 27

    XSLT set table background color when

  28. 28

    Add Background Color to Listview's Specific Row

  29. 29

    How to set alternative row color and background color of jqgrid

HotTag

Archive