canvas-save.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. error_reporting(E_ALL);
  3. ini_set('display_errors', 1);
  4. // Require composer autoload
  5. require_once __DIR__ . '/vendor/autoload.php';
  6. // Create an instance of the class in landscape
  7. $mpdf = new mPDF('c', 'A4-L', '', 5, 7, 3, 7);
  8. // Use a style sheet
  9. $stylesheet = file_get_contents('canvas-pdf.css');
  10. $mpdf->WriteHTML($stylesheet, 1);
  11. // Write some HTML code
  12. $title = $_POST['field_00']; // Returns an array
  13. $field1Items = $_POST['field_01'];
  14. function fillItems($field_name){
  15. $item = '';
  16. $fieldItems = $_POST[$field_name];
  17. for($i = 0; $i < count($fieldItems); $i++){
  18. $item .= '<ul class="items"><li>' . $fieldItems[$i] . '</li></ul>';
  19. }
  20. return $item;
  21. }
  22. // $items_01 = '';
  23. // $field1Items = $_POST['field_01'];
  24. // for($i = 0; $i<count($field1Items); $i++){
  25. // $items_01 .= '<ul class="items"><li>'.$field1Items[$i].'</li></ul>';
  26. // }
  27. $html = '<div class="wrapper">
  28. <div class="page_title">
  29. <div class="logo"><div class="logo-icon"></div><h1 class="ethics-title">Online Ethics Canvas</h1></div>
  30. <div class="project_title"><span>Canvas Title: </span>' . $title[0] . '</div>
  31. <div class="project_date"><span>Date: </span>' . $title[1] . '</div>
  32. </div>
  33. <!-- end of .page_title -->
  34. <div class="row1">
  35. <div class="card field_01"><h3>Individuals Affected</h3>' . fillItems("field_01") . '
  36. <div class="field-icons"></div>
  37. </div>
  38. <div class="card field_02"><h3>Groups Affected</h3>' . fillItems("field_02") . '
  39. <div class="field-icons"></div>
  40. </div>
  41. <div class="card field_03"><h3>Behaviour</h3>' . fillItems("field_03") . '
  42. <div class="field-icons"></div>
  43. </div>
  44. <div class="card field_04"><h3>Relations</h3>' . fillItems("field_04") . '
  45. <div class="field-icons"></div>
  46. </div>
  47. <div class="card field_05"><h3>Worldviews</h3>' . fillItems("field_05") . '
  48. <div class="field-icons"></div>
  49. </div>
  50. </div>
  51. <!-- end of Row1 -->
  52. <div class="row2">
  53. <div class="card field_06"><h3>Group Conflicts</h3>' . fillItems("field_06") . '
  54. <div class="field-icons"></div>
  55. </div>
  56. <div class="card field_07"><h3>Product or Service Failure</h3>' . fillItems("field_07") . '
  57. <div class="field-icons"></div>
  58. </div>
  59. <div class="card field_08"><h3>Problematic Use of Resources</h3>' . fillItems("field_08") . '
  60. <div class="field-icons"></div>
  61. </div>
  62. <div class="card field_09"><h3>What can we do?</h3>' . fillItems("field_09") . '
  63. <div class="field-icons"></div>
  64. </div>
  65. <div class="card field_10"><h3>Uncategorised Ideas</h3>' . fillItems("field_10") . '
  66. <div class="field-icons"></div>
  67. </div>
  68. </div>
  69. <!-- end of Row2 -->
  70. <!--
  71. <footer class="col-md-12 text-center">
  72. <p class="ethics-copy">Ethics Canvas v1.8</p>
  73. <p class="ethics-copy">&copy; ADAPT Center, 2017</p>
  74. </footer>
  75. -->
  76. </div>';
  77. $mpdf->WriteHTML($html, 2);
  78. // Output a PDF file directly to the browser
  79. $mpdf->Output('../saved-pdf/Ethics-Canvas.pdf', 'F');
  80. // Add 'D' parameter for download
  81. // $mpdf->Output('MyEthicsCanvas.pdf', 'D');
  82. ?>