I want to give navy light blue color through out pdf backgound color
+1
Workaround:
var dd = {
pageSize: {
width: 595.28,
height: 841.89
},
background: function () {
return {
canvas: [
{
type: 'rect',
x: 0, y: 0, w: 595.28, h: 841.89,
color: '#00BFFF'
}
]
};
},
content: [
{text: 'Simple text 1', pageBreak: 'after'},
{text: 'Simple text 2', pageBreak: 'after'},
{text: 'Simple text 3', pageBreak: 'after'}
]
};
@liborm85
Is there any chance to give distinct bgcolor for each page?
Thanks, @liborm85
Got the solution:
const colors = [ '#CD5C5C', '#F08080', '#008000' ];
this.docDefinition.background = (index) => {
const canvas = [
{
type: 'rect',
x: 0, y: 0, w: 595.28, h: 841.89,
color: colors[index - 1]
}
];
return {canvas};
};
@StevensonNelli it works great in Firefox/Chrome to alternate bg for different pages, but it fails with a syntax error in IE 11. Have you had any success with getting alternate page backround in IE?
@StevensonNelli worked it out. IE doesn't support " => "
so rewritten the script to be
``` const colors = [ '#007b3d', '#f9c100', '#f08714' ];
this.dd.background = function (index) {
var canvas = [{
type: 'rect',
x: 0,
y: 0,
w: 595.28,
h: 841.89,
color: colors[index - 1]
}];
return {
canvas: canvas
};
};
```
Most helpful comment
Workaround: