pageMargins not applied to header and footer
Hi,
the page margins are not applied to the header and footer., did someone come across this issue.? a simple playground test will replicate the issue..
var dd = {
header: {
stack: [
{text: 'hello-header'}
]
},
footer: {
stack: [
{text: 'hello-footer'}
]
},
content: [
{
table: {
widths: ['*', '*'],
body: [
['', '']
]
}
}
],
pageSize: 'LETTER'
}
and any pageMargins given are applied only to the content
You have to set the margins on headers and footers (ensure they have enough space to render by specifying an appropriate value for pageMargins)
Here is an example
var dd = {
header: {
stack: [
{text: 'hello-header'}
],
margin: [72,40]
},
footer: {
stack: [
{text: 'hello-footer'}
],
margin: [72,40]
},
content: [
{
table: {
widths: ['*', '*'],
body: [
['', '']
]
}
}
],
pageSize: 'LETTER',
pageMargins: 72
}
please consider the following example, the header doesnt show up inspite of having enough margin
// playground requires you to assign document definition to a variable called dd
var dd = {
header: function(){
return {
table: {
body: [
[
{image: 'bot_head'},
]
]
}, margin: [72,40]
};
},
footer: function(){
return {
table: {
body: [
[
{image: 'bot_head'},
]
]
}, margin: [72,40]
};
},
content: {
stack:[
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines',
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines',
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines',
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines',
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines',
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines',
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines',
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines',
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines',
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines',
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines',
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines',
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines',
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines',
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines'
]
},
images:{
bot_head: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEMAAABMCAYAAAA2nAqmAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABJBJREFUeNrsm89u0zAYwJ1pt1Vqb+utkca9eYNmAmnc1jdYDwiOK/AA7Z5gRQIkEFKDBBIHppUbk0DLnmDpnWnlxk7rpO487PJNeJ7t2GmcP00+yUrXpf2cnz9//5JaKAX58dNv4kMXDxvemuIxePTQPUEpipUCiB188AT/7mAgHwsBA4No4MMk5DQbA/mdBoyVhPV1mL99GLR007KM1YT1udTrAFvAJljMKT448L5TFBhTejtgCFV4XUMZkKS3Cb0lagBnQkUVIqOiwPA4DrTGWI5XCBjYR1zhQ1sQUch7LpxTjDwDHGaLE0XctJOuFVRKCaOEUcIoYZQwShhZzzOgZ+EyaTabdbIFWcDULrykbIRzkW+5gAEdrJEEQlz1TdtEproSI4gqTNQ2bM0uJ3vNnM8YJFiKOxh+L8swOgn7u04mYUDhlbTEvh2tBfxDm4oYbooR0YdI40O0uUoEBnS3+ylsCVWZgu8aRIFiaVjCIMMQeFA6ujmJpQBiG/1rxdVQ/oTMu6tqJVYIiB5sizwLyWyV2omWBMRQc1v4YJ5BAlFE12krAVldEIRnul5Q2MJthbk6UCZsalkGVrALzjLMCjpp3RMVRDlPwVpIlHmuBAMKrTAzT/VOeQgUlYUUduHZDHQUEq6crIIgguf2SmHLeKHpOEQOO4ToOOuhAxZLBsSGfgsfBiRVskcBunkAwQCRpQR9mWV0JEmVD+aXK8Fz3pP4P6513MLoZqg0j1Nk19W+BwMiiMhXeFkJnxGt40RiHW2eZbhRPG+OZKDah5HBmKZ9VzwmkaULLgvDlmSZuReoRwJJnXMHhiMpbpZFJqowdL8gr2V8qKxKkhN/iWD4guu8t+A3gtFaIhg9wTUeq26TwkkJo4QhdqBalZ2i5yaZq2qVe9u6syPqIs4xlrajBY7ElAcnRZ6otmkBNDsGXQHoohdgn8qhbIGeCVty3Bgcl3g0OZPYMaRrm9JxGOE7jMIg4xyPKjXJpmH4jZBwKhxJOFCb6SsMDOqqLVpp3yQwLhOwCno0oliG9Mc3a2sVtLX1GFUqFSWq43EwH4IVa8l6J+vr9bkuVTk6+o4uLv7IulgTqqQQOdA7dwCl0eTT5y+oXq9rmdnLF10RkC76/0zHPRDv3n9Qhk5kNpuhZ0+fiICQtGCPScf7goi3GZp0EavQBUFkY+OBbD9zhejRAUGEnK/7GZUMlLuM19cz9PbN6/kK6JguGZK8YyLaXpLPca3i4OArOjv7tej1O0ykQ8OEnBpRupuQLrbi3g0J/T0Y8w+antwhTKqRUF7DiqreuRwbnmCTSZNN6toWbIljVRhVyAVMTI69c0V0nRrSNZT4h4bCNd45Oc5JXnJA0EDitsZ9BYfZDAHCbZGdLwhhSNUIMtmJYQEONVuUDdFCWCEf0i2vp2wfA56qob9nyrmjH0XXbeke9SHYJpT9Dp2BGhMAEXASrj7cJS9U288RZJ5uEXugrub7hYSR1i8R0oEBj0Y5UUAto2W4C/5/qWA4JQyNi82a30gVRtaswwgMjRV3i2AZAVJ7QMTLEoy/AgwAS/Y0W/Yhy/IAAAAASUVORK5CYII="
},
pageSize: 'LETTER',
pageMargins: [72,150]
};
the image included has a width of 60 & a height of 67 I am trying to apply a similar template to a invoice management system, and the layout breaks for some invoices and is perfect for some, and i get into a situation where i have to tweak the margins for the ones where it doesn't work and all of a sudden the once's which were working break. Is there a some layout guide or some math that we should be aware of ?
this is a bug as the room available to header is miscalculated
pull request #84 fix this issue
until the pull request get merged, you can checkout the code at my fork https://github.com/yelouafi/pdfmake
but i recommend to re-checkout the mainstream library as soon the pull get meged.
As for your example you may check this plunker
Note however that the exact height of your header is 162 as the total height is
- image : 76 (yes yes i checked it in the debugger, should use fit: [ width, height] to be sure)
- table rows border: default 1 per line x 2 (top and bottom) = 2
- table cells padding : default 2 x 2 (top and bottom) = 4
- headers margins: 40 x 2 = 80
so 76 + 2 + 4 + 80 = 162
merged ;)
Thanks guys, i'll check it out..!
Cheers!
Hi, How can i add line above footer
Hi, How can i add line above footer
private pageFooter(currentPage, pageCount) {
return [
{ text:Page ${currentPage} of ${pageCount}, alignment: 'right' },
{ canvas: [{ type: 'line', x1: 10, y1: 3, x2: 595 - 10, y2: 3, lineWidth: 0.5 }] },
];
}