Export PDF inserting a custom header and footer
Export PDF inserting a custom header and footer
Haas
Posts: 1Questions: 0Answers: 0
Hi.
I need a header and a custom with some more tags. Lines and columns that I would export with PDF button.
How I could do it using the customize function?
{
text: '<i class="fa fa-file-pdf-o" aria-hidden="true" title="Listagem"></i> AGR',
className: 'btn btn-info',
extend: 'pdfHtml5',
//messageBottom: function () {
// var dateNow = new Date();
// return "<tr><td>haas</td><td>teste</td></tr> Usuário: " + $('#Usuario').text() + " - Data: " + dateNow.toLocaleString();
//},
//messageTop: 'haas',
title: 'Listagem \n\n' + $('#lblDestino').text() + ' ' + $('#lblPeriodo').text(),
//orientation: 'landscape',
//pageSize: 'A4',
footer: false,
download: 'open',
exportOptions: {
columns: [1, 0, 5],
stripNewlines: false
},
customize: function (doc) {
//debugger;
//doc.content[1].table.header.html = '<tr><td>haas</td><td>teste</td></tr>';
var rowCount = doc.content[1].table.body.length;
for (i = 1; i < rowCount; i++) {
doc.content[1].table.body[i][0].text = i;
};
doc.content[1].table.body[0][0].text = 'Nº';
doc.content[1].table.body[0][1].text = 'NOME DO PASSAGEIRO';
doc.content[1].table.body[0][2].text = 'Nº IDENTIDADE/ORGÃO EXP.';
doc.pageMargins = [10, 20, 10, 10];
doc.defaultStyle.fontSize = 7;
doc.styles.tableHeader.fontSize = 7;
doc.styles.title.fontSize = 9;
// Remove spaces around page title
doc.content[0].text = "HHAAAASS" + doc.content[0].text.trim()+"HHHHHHHHHHAAAAAAAAAAAASSSSSSSSSSS";
// Create a footer
doc['footer'] = (function (page, pages) {
return {
columns: [
UsuarioData(),
{
// This is the right column
alignment: 'right',
text: ['Página ', { text: page.toString() }, ' de ', { text: pages.toString() }]
}
],
//margin: [10, 0]
}
});
// Create a header
doc['header'] = (function (page, pages) {
return {
columns: [
{
//image: ''; //width: 80
}
],
margin: [10, 10],
content: [
{ text: 'This is a header', style: 'header' },
'No styling here, this is a standard paragraph'
]
}
});
I need insert more lines and coluns infortations in the header and footer.
How?
With the best regards.
Haas
This discussion has been closed.