Stick footer PDF Export
Stick footer PDF Export
pzd060
Posts: 1Questions: 0Answers: 0
Hi all,
I saw some questions and no answer about sticky footer, so I am pasting the code I came up with. Somebody may need to use it.
customize: function(doc) {
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10){
dd='0'+dd
}
if(mm<10){
mm='0'+mm
}
var today = mm+'/'+dd+'/'+yyyy;
var cols = [];
cols[0] = {text: 'PRINT NAME AND TITLE', alignment: 'left', margin:[10] };
cols[1] = {text: 'DATE:', alignment: 'right', margin:[0,0,20] };
var objFooter = {};
objFooter['alignment'] = 'center';
doc["footer"] = function(currentPage, pageCount) {
var footer = [
{
alignment: 'left',
stack: [
{
canvas: [
{
type: 'line',
x1: 20,
y1: 5,
x2: 133,
y2: 5,
lineWidth: 0.5
}
]
},
{
text: 'PRINT NAME AND TITLE',
alignment: 'left',
margin:[20, 5, 0, 0]
},
{
text: today,
color: 'grey',
fontSize: 8,
alignment: 'left',
margin:[20, 2, 0, 0]
}
]
},
{
stack: [
{
canvas: [
{
type: 'line',
x1: 240,
y1: 5,
x2: 286,
y2: 5,
lineWidth: 0.5
}
]
},
{
text: 'DATE',
alignment: 'right',
margin:[0, 5, 20, 0]
},
{
text: 'Page '+currentPage+" of "+pageCount,
alignment: 'right',
color: 'grey',
fontSize: 8,
margin:[0, 2, 20, 0]
}
]
}
];
objFooter['columns'] = footer;
return objFooter;
};
}
This is returning some text and a line (on top) on the right side, below it the current date.
More text and a line (on top) on the left side and then below - the current page of the report.
Cheers
This discussion has been closed.