3

I have a string which i want to set as the heading of the pdf. I tried it using the following code. But the background is not coming properly. I want to set the background color to the entire row, but it is coming just under text. Any help would be highly appreciated.

var dd = {

    content: [
            {
        text: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.',
        style: 'header'
      },
],
    styles: {
        header: {
            fontSize: 18,
            bold: true,
            margin: [0, 0, 0, 10],
            background:'blue',
            color: 'white',
            alignment:'center'
        }
    },
    defaultStyle: {
        // alignment: 'justify'
    }

}
YouBee
  • 1,981
  • 1
  • 15
  • 16

1 Answers1

6

It seems there is no possible way of setting the background color and padding of text. I tried an alternate solution by creating the table with only its header having one single columns without borders and it worked for my scenario.

    var dd = {
            content: [


            {
                style: 'header',
                table: {
                    widths:'*',
                    body: [
                        [{
                                border: [false, false, false, false],
                                fillColor: '#5bc0de',
                                text: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.'
                            }]
                    ]
                }
            },


        ]
}
YouBee
  • 1,981
  • 1
  • 15
  • 16