Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let docDefinition = {
- pageSize : 'A4',
- pageMargins : [25, 25, 25, 35],
- pageOrientation: 'landscape',
- defaultStyle : {
- fontSize : 12,
- columnGap : 20
- },
- // Page Layout
- content : {
- // This table will contain ALL content
- table : {
- // Defining the top 2 rows as the "sticky" header rows
- headerRows: 3,
- // One column, full width
- widths: ['*'],
- body: [
- // Header Row One
- // An array with just one "cell"
- [
- // Just because I only have one cell, doesn't mean I can't have
- // multiple columns!
- {
- columns : [
- {
- width : '80%',
- text : postPayload.reportName,
- fontSize : 26,
- bold : true
- }
- ]
- }
- ],
- // Second Header Row
- [
- {
- columns: [
- {
- width: 'auto',
- margin: [0,0,10,0],
- text: [
- { text: 'Report generated by [Name]n', fontSize: 16, bold: true, color: '#63798a' },
- { text: `${metadata.user}`, fontSize: 14 }
- ]
- },
- {
- width: 'auto',
- margin: [0,0,10,0],
- text: [
- { text: 'Report generated by [NTID] n', fontSize: 16, bold: true, color: '#63798a' },
- { text: `${metadata.ntid}`, fontSize: 14 }
- ]
- },
- {
- width: 'auto',
- margin: [0,0,10,0],
- text: [
- { text: 'Report generated on n', fontSize: 16, bold: true, color: '#63798a' },
- { text: `${metadata.timestamp}`, fontSize: 14 }
- ]
- },
- {
- width: 'auto',
- margin: [0,0,10,0],
- text: [
- { text: 'Result count n', fontSize: 16, bold: true, color: '#63798a' },
- { text: `${content.length}`, fontSize: 14 }
- ]
- }
- ]
- }
- ],
- [{ unbreakable: true,
- table: {
- headerRows: 1,
- widths: postPayload.colDefs.map(header => `${100 / postPayload.colDefs.length}%`),
- body: tableData
- }
- }]
- ]
- },
- layout: {
- hLineWidth: function(i, node) { return (i === 1 || i === 2) ? 1 : 0; },
- vLineWidth: function(i, node) { return 0; },
- hLineColor: function(i, node) { return (i === 1 || i === 2) ? '#eeeeee' : 'white'; },
- vLineColor: function(i, node) { return 'white' },
- paddingBottom: function(i, node) {
- switch (i) {
- case 0:
- return 5;
- case 1:
- return 2;
- default:
- return 0;
- }
- },
- paddingTop: function(i, node) {
- switch (i) {
- case 0:
- return 0;
- case 1:
- return 2;
- default:
- return 10;
- }
- }
- }
- },
- footer : function(current, count) {
- return {
- columns: [{
- text: 'Pfizer Internal Use',
- alignment: 'right',
- opacity: 0.6,
- fontSize: 14,
- }, {
- text: `${current.toString()} / ${count}`,
- alignment: 'right',
- opacity: 0.6,
- fontSize: 14,
- margin: [0, 10, 30, 10],
- }]
- }
- },
- };
- this.downloadPDF().then(function(results) {
- const pdfDocGenerator = pdfMake.createPdf(results);
- pdfDocGenerator.open();})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement