Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.58 KB | None | 0 0
  1. let docDefinition = {
  2. pageSize : 'A4',
  3. pageMargins : [25, 25, 25, 35],
  4. pageOrientation: 'landscape',
  5. defaultStyle : {
  6. fontSize : 12,
  7. columnGap : 20
  8. },
  9. // Page Layout
  10. content : {
  11. // This table will contain ALL content
  12. table : {
  13. // Defining the top 2 rows as the "sticky" header rows
  14. headerRows: 3,
  15. // One column, full width
  16. widths: ['*'],
  17. body: [
  18. // Header Row One
  19. // An array with just one "cell"
  20. [
  21. // Just because I only have one cell, doesn't mean I can't have
  22. // multiple columns!
  23. {
  24. columns : [
  25. {
  26. width : '80%',
  27. text : postPayload.reportName,
  28. fontSize : 26,
  29. bold : true
  30. }
  31. ]
  32. }
  33. ],
  34. // Second Header Row
  35. [
  36. {
  37. columns: [
  38. {
  39. width: 'auto',
  40. margin: [0,0,10,0],
  41. text: [
  42. { text: 'Report generated by [Name]n', fontSize: 16, bold: true, color: '#63798a' },
  43. { text: `${metadata.user}`, fontSize: 14 }
  44. ]
  45. },
  46. {
  47. width: 'auto',
  48. margin: [0,0,10,0],
  49. text: [
  50. { text: 'Report generated by [NTID] n', fontSize: 16, bold: true, color: '#63798a' },
  51. { text: `${metadata.ntid}`, fontSize: 14 }
  52. ]
  53. },
  54. {
  55. width: 'auto',
  56. margin: [0,0,10,0],
  57. text: [
  58. { text: 'Report generated on n', fontSize: 16, bold: true, color: '#63798a' },
  59. { text: `${metadata.timestamp}`, fontSize: 14 }
  60. ]
  61. },
  62. {
  63. width: 'auto',
  64. margin: [0,0,10,0],
  65. text: [
  66. { text: 'Result count n', fontSize: 16, bold: true, color: '#63798a' },
  67. { text: `${content.length}`, fontSize: 14 }
  68. ]
  69. }
  70. ]
  71. }
  72. ],
  73.  
  74. [{ unbreakable: true,
  75. table: {
  76. headerRows: 1,
  77. widths: postPayload.colDefs.map(header => `${100 / postPayload.colDefs.length}%`),
  78. body: tableData
  79. }
  80. }]
  81. ]
  82. },
  83. layout: {
  84. hLineWidth: function(i, node) { return (i === 1 || i === 2) ? 1 : 0; },
  85. vLineWidth: function(i, node) { return 0; },
  86. hLineColor: function(i, node) { return (i === 1 || i === 2) ? '#eeeeee' : 'white'; },
  87. vLineColor: function(i, node) { return 'white' },
  88. paddingBottom: function(i, node) {
  89. switch (i) {
  90. case 0:
  91. return 5;
  92. case 1:
  93. return 2;
  94. default:
  95. return 0;
  96. }
  97. },
  98. paddingTop: function(i, node) {
  99. switch (i) {
  100. case 0:
  101. return 0;
  102. case 1:
  103. return 2;
  104. default:
  105. return 10;
  106. }
  107. }
  108. }
  109. },
  110. footer : function(current, count) {
  111. return {
  112. columns: [{
  113. text: 'Pfizer Internal Use',
  114. alignment: 'right',
  115. opacity: 0.6,
  116. fontSize: 14,
  117. }, {
  118. text: `${current.toString()} / ${count}`,
  119. alignment: 'right',
  120. opacity: 0.6,
  121. fontSize: 14,
  122. margin: [0, 10, 30, 10],
  123. }]
  124. }
  125. },
  126.  
  127.  
  128. };
  129.  
  130. this.downloadPDF().then(function(results) {
  131. const pdfDocGenerator = pdfMake.createPdf(results);
  132. pdfDocGenerator.open();})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement