PHP dynamic HTML to PDF certificate with mPDF -


looking way output php dynamic html certificate looking document pdf - have html certificate looking fine, when use mpdf return html results pdf, nothing. i'm sure it's way html stored in php var , scripts need outside html, i'm not sure how accomplish this?

<?php  $html = ' <html> <head> <!-- saved url=(0014)about:internet --> <title>certificate</title>  <script> var strtitle = "miemss course title";  var g_arrmonths = new array()  // enter month names below try { g_arrmonths[0] = __month_jan__;  g_arrmonths[1] = __month_feb__; g_arrmonths[2] = __month_mar__; g_arrmonths[3] = __month_apr__; g_arrmonths[4] = __month_may__; g_arrmonths[5] = __month_jun__; g_arrmonths[6] = __month_jul__; g_arrmonths[7] = __month_aug__; g_arrmonths[8] = __month_sep__; g_arrmonths[9] = __month_oct__; g_arrmonths[10] = __month_nov__; g_arrmonths[11] = __month_dec__;  // enter column headers var g_strdatetime       = __date_time__; var g_strstudentscore   = __student_score__; var g_strpassingscore   = __passing_score__; var g_strresult1        = __result__; var g_strquestion       = __question__; var g_strcorrectans     = __correct_ans__; var g_strresult2        = __result__; var g_strstudentans     = __student_ans__; var g_strpointsawarded  = __points_award__; var g_strneutral        = __neutral__; var g_strcorrect        = __correct__; var g_strincorrect      = __incorrect__; } catch(e) { g_arrmonths[0] = "january";  g_arrmonths[1] = "february"; g_arrmonths[2] = "march"; g_arrmonths[3] = "april"; g_arrmonths[4] = "may"; g_arrmonths[5] = "june"; g_arrmonths[6] = "july"; g_arrmonths[7] = "august"; g_arrmonths[8] = "september"; g_arrmonths[9] = "october"; g_arrmonths[10] = "november"; g_arrmonths[11] = "december";  // enter column headers var g_strdatetime = "date / time"; var g_strstudentscore = "student score"; var g_strpassingscore = "passing score"; var g_strresult1 = "result"; var g_strquestion = "question"; var g_strcorrectans = "correct answer"; var g_strresult2 = "result"; var g_strstudentans = "student answer"; var g_strpointsawarded = "points awarded"; var g_strneutral = "neutral"; var g_strcorrect = "correct"; var g_strincorrect = "incorrect"; }  </script>  <style>  td { font-size:10pt; font-family:arial; text-align: center; width: 12.5%; }  .correct { font-size:10pt; font-family:arial; color: #008800; }  .incorrect { font-size:10pt; font-family:arial; color: #880000; }  .neutral { font-size:10pt; font-family:arial; color: #000088; }  .question { font-size:10pt; font-family:arial; text-align: left; width: 46.25%;   }  .number { font-size:10pt; font-family:arial; text-align: center; width: 3.75%; }  .date { font-size:10pt; font-family:arial; text-align: center;  }  .datetime { font-size:10pt; font-family:arial; margin-top: 0; margin-bottom: 0; }  .summary { font-size:10pt; font-family:arial; text-align: center; }  h1 { font-size:14pt; font-family:arial; text-align: center; }  th { font-size:12pt; font-family:arial; }  .image {     position: relative;     width: 100%; /* ie 6 */ }  h2 { font-size:14pt; font-family:arial; text-align: center; position: absolute;  top: 200px;  left: 0;  width: 100%;  }  </style>  <script> var g_ocontentresults = window.opener.g_ocontentresults; var g_listquizzes = window.opener.g_listquizzes; var g_oprintoptions = window.opener.g_oprintoptions;  var player = getplayer()     //var myscore = player.getvar("g_strstudentscore"); var scoretotal = player.getvar("userscore").tostring();  function formatdate(dtmdate) { var strresult = ""; var nhours = dtmdate.gethours(); var stram = "am"; var nminutes = dtmdate.getminutes(); var strminutes = "" + nminutes;  if (nminutes < 10) {     strminutes = "0" + nminutes; }  if (nhours == 12) {     stram = "pm"; }  if (nhours > 12) {     nhours -= 12;     stram = "pm"; }   strresult += "<p>" strresult += g_arrmonths[dtmdate.getmonth()] + " "; strresult += dtmdate.getdate() + ", "; strresult += dtmdate.getfullyear() + "  "; strresult += nhours + ":"; strresult += strminutes + " "; strresult += stram; strresult += "</p>" return strresult; }  </script>  </head> <body> <center> <img src="quizimages/cert.png"> </center> <p> <script>  //document.write("<p><h1>" + strtitle + "</h1></p>");  if (g_oprintoptions.strname) { if (g_oprintoptions.strname.length > 0) {     document.write("<h2><center><i>this certifies:</i></br></br>");     document.write("" + g_oprintoptions.strname + "</br></br>");     document.write("<i>has completed course:</i></br></br>");     document.write("" + strtitle + "</br></br>");     document.write("</br></br>");     document.write( formatdate(g_ocontentresults.dtmfinished));     document.write("score: " + g_listquizzes[g_oprintoptions.strmainquizid].nptscore + "</br></br></h2>" );          document.write('<center> <input type=button onclick="window.print()" value="print page"/> </center>'); } }       document.write("user score: "+scoretotal+"");       document.write("<h2><center><i>this certifies:</i></br></br>");     document.write("" + g_ocontentresults.strname + "</br></br>");     document.write("<i>has completed course:</i></br></br>");     document.write("" + strtitle + "</br></br>");     document.write("</br></br>");     document.write( formatdate(g_ocontentresults.dtmfinished));     document.write("score: " + g_listquizzes[g_ocontentresults.strmainquizid].nptscore + "</br></br></h2>" );            document.write('<center> <input type=button onclick="window.print()" value="print page"/> </center>');   </script> </body> </html> ';   //============================================================== //============================================================== //==============================================================  include("../mpdf/mpdf.php"); $mpdf=new mpdf('c');   $mpdf->writehtml($html); $mpdf->output(); exit;  //============================================================== //============================================================== //==============================================================   ?> 

the javascript variables in html load after php page drawn. javascript var needs passed php var via post, get, or query string , picked in refresh or new page - $html needs html , not contain script.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -