<?php
  // form_creator.php
  // RJM Programming
  // October, 2019
  // Create PDF forms.

//Based on HTML2PDF by Clément Lavoillotte
//Thanks to http://www.fpdf.org/en/script/script50.php

if (is_file('MarkItUp/fpdf17/fpdf.php')) {
require('MarkItUp/fpdf17/fpdf.php');
} else {
require('../MarkItUp/fpdf17/fpdf.php');
}

const MAX_P_WIDTH = 595; //1150;
const MAX_P_HEIGHT = 842; //1650;

const MAX_L_HEIGHT = 595; //1150;
const MAX_L_WIDTH = 842; //1650;

$wasphpcode=file_get_contents(dirname(__FILE__) . '/form_creator.php');

$pollid=0;
$pollers=[","];

// Data below ...
// Data above ...

if (isset($_GET['collate'])) {
    $bits=explode('/' . '/ ?', $wasphpcode);
    $csvis="";
    for ($ij=1; $ij<sizeof($bits); $ij++) {
      $arec=explode("\n", $bits[$ij])[0];
      if (strpos($arec, "&ipollid=") !== false) {
        $plid=explode("&", explode("&ipollid=", $arec)[1])[0];
        $arec=str_replace("&ipollid=" . $plid, "", $arec);
        if ($csvis == "") {
          $csvis='"Poller Number","Timestamp","Favourite anything","Favourite integer","Favourite colour","Favourite file","Favourite email","Favourite url","Favourite date","Favourite time","Favourite month"' . "\n";
        }
        if (strpos($arec, "&timestamp=") !== false) {
          $ts=explode("&", explode("&timestamp=", $arec)[1])[0];
          // Initialising a DateTime 
          date_default_timezone_set('GMT');
          //$datetime = gmdate("M d Y H:i:s", mktime(0, 0, 0, 1, 1, 1970)); //new DateTime('2019-09-30');
          $xdatetime = new DateTime('1970-01-01 00:00:00'); 
          // DateInterval object is taken as the  
          // parameter of the add() function 
          // Here lots of seconds added 
          $dis=(($ts - ($ts % (24 * 60 * 60))) / (24 * 60 * 60));
          $hrs=floor(($ts % (24 * 60 * 60)) / (60 * 60));
          $mins=floor(($ts % (60 * 60)) / 60);
          $secs=floor(($ts % 60));
          
          $xdatetime->add(new DateInterval('P' . $dis . 'D')); 
          $xdatetime->add(new DateInterval('PT' . $hrs . 'H')); 
          $xdatetime->add(new DateInterval('PT' . $mins . 'M')); 
          $xdatetime->add(new DateInterval('PT' . $secs . 'S')); 

          $arec=str_replace("&timestamp=" . $ts, "", $arec);
          $brec='"' . $plid . '","' . $xdatetime->format('Y-m-d H:i:s') . " GMT" . '","' . str_replace("+"," ",urldecode(explode("&", explode("fa=", $arec)[1])[0])) . '","' . str_replace("+"," ",urldecode(explode("&", explode("fn=", $arec)[1])[0])) . '","' . str_replace("+"," ",urldecode(explode("&", explode("fc=", $arec)[1])[0])) . '","' . str_replace("+"," ",urldecode(explode("&", explode("ff=", $arec)[1])[0])) . '","' . str_replace("+"," ",urldecode(explode("&", explode("fe=", $arec)[1])[0])) . '","' . str_replace("+"," ",urldecode(explode("&", explode("fu=", $arec)[1])[0])) . '","' . str_replace("+"," ",urldecode(explode("&", explode("fd=", $arec)[1])[0])) . '","' . str_replace("+"," ",urldecode(explode("&", explode("ft=", $arec)[1])[0])) . '","' . str_replace("+"," ",urldecode(explode("&", explode("fm=", $arec)[1])[0])) . '"' . "\n";
        } else {
          $brec='"' . $plid . '","","' . str_replace("+"," ",urldecode(explode("&", explode("fa=", $arec)[1])[0])) . '","' . str_replace("+"," ",urldecode(explode("&", explode("fn=", $arec)[1])[0])) . '","' . str_replace("+"," ",urldecode(explode("&", explode("fc=", $arec)[1])[0])) . '","' . str_replace("+"," ",urldecode(explode("&", explode("ff=", $arec)[1])[0])) . '","' . str_replace("+"," ",urldecode(explode("&", explode("fe=", $arec)[1])[0])) . '","' . str_replace("+"," ",urldecode(explode("&", explode("fu=", $arec)[1])[0])) . '","' . str_replace("+"," ",urldecode(explode("&", explode("fd=", $arec)[1])[0])) . '","' . str_replace("+"," ",urldecode(explode("&", explode("ft=", $arec)[1])[0])) . '","' . str_replace("+"," ",urldecode(explode("&", explode("fm=", $arec)[1])[0])) . '"' . "\n";
        }
        $csvis.=$brec;
      }
    }
    if ($csvis != "") {
      header('Content-type: text/csv');
      header('Content-disposition: attachment;filename=form_creator.csv'); 
      echo $csvis;
      exit;
    }
} else if (isset($_GET['ipollid'])) {

  if (strpos($wasphpcode, "&" . "ipo" . "llid=" . urldecode($_GET['ipollid']) . "&") !== false) {
    $bits=explode("&" . "ipo" . "llid=" . urldecode($_GET['ipollid']) . "&", $wasphpcode);
    $prebits='/' . '/ ?' . explode('?', $bits[0])[-1 + sizeof(explode('?', $bits[0]))] . "&" . "ipo" . "llid=" . urldecode($_GET['ipollid']) . "&" . explode("\n", $bits[1])[0] . "\n";
    $isphpcode=str_replace($prebits, '/'. '/ ?' . $_SERVER['QUERY_STRING'] . '&timestamp=' . urlencode($_SERVER['REQUEST_TIME']) . "\n",$wasphpcode);
    file_put_contents(dirname(__FILE__) . '/form_creator.php', $isphpcode);
    header("Location: //www.rjmprogramming.com.au/HTMLCSS/oninvalid.html?was" . str_replace("&", "&was", explode("\n", explode("?", $prebits)[1])[0]) . "&" . $_SERVER['QUERY_STRING']);
    exit;
  } else {
    $isphpcode=str_replace('/'. '/ Dat' . 'a abo' . 've ..' . '.', '/'. '/ ?' . $_SERVER['QUERY_STRING'] . '&timestamp=' . urlencode($_SERVER['REQUEST_TIME']) . "\n" . '/'. '/ Dat' . 'a abo' . 've ..' . '.',$wasphpcode);
    file_put_contents(dirname(__FILE__) . '/form_creator.php', $isphpcode);
    header("Location: //www.rjmprogramming.com.au/HTMLCSS/oninvalid.html?" . $_SERVER['QUERY_STRING']);
    exit;
  }
} else if (isset($_GET['pollerquery'])) { 
  $ibit="";    
  $eis=strtolower(str_replace('+',' ',urldecode($_GET['pollerquery'])));
  if (strpos($eis, "@") !== false) {
  if (strpos($wasphpcode . ',', ',' . $eis . ',') !== false) {
  $plst=explode(",", substr($pollers[0],1));
  for ($ii=0; $ii<sizeof($plst); $ii++) {
    if (strtolower($eis) == strtolower($plst[$ii])) {
      $pollid=$ii;
  if (strpos($wasphpcode, "&" . "ipo" . "llid=" . $pollid . "&") !== false) {
    $bits=explode("&" . "ipo" . "llid=" . $pollid . "&", $wasphpcode);
    $prebits='?' . explode('?', $bits[0])[-1 + sizeof(explode('?', $bits[0]))] . "&" . "ipo" . "llid=" . $pollid . "&" . explode("\n", $bits[1])[0];
  echo "<html><body onload=\"  parent.document.getElementById('ipollid').value='" . $pollid . "';  window.open('//www.rjmprogramming.com.au/HTMLCSS/oninvalid.html" . $prebits . "','_blank','top=20,left=20,width=700,height=950'); \"></body></html>";
    exit;
  }
      }
  }
  }
  }
  echo "<html><body onload=\" parent.document.getElementById('ipollid').value='" . $pollid . "';  alert('No previous Favourites recorded for your email.'); \"></body></html>";
  exit;
} else if (isset($_GET['polleremail'])) { 
  $ibit="";    
  $eis=strtolower(str_replace('+',' ',urldecode($_GET['polleremail'])));
  if (strpos($eis, "@") !== false) {
  if (strpos($wasphpcode . ',', ',' . $eis . ',') === false) {
    $isphpcode=str_replace('"' . ']' . ';', $eis . ',"' . ']' . ';',$wasphpcode);
    file_put_contents(dirname(__FILE__) . '/form_creator.php', $isphpcode);
  }
  $plst=explode(",", substr($pollers[0],1));
  for ($ii=0; $ii<sizeof($plst); $ii++) {
    if (strtolower($eis) == strtolower($plst[$ii])) {
      $pollid=$ii;
    }
  }
  // $imgdis=file_get_contents('HTTP://www.rjmprogramming.com.au/MyBusinessUnidad/Welcome_files/logo.jpg');
  // $ibit=" parent.document.getElementById('imgpoll').src='" . 'data:image/jpeg;base64,' . base64_encode($imgdis) . "'; ";
  }
  echo "<html><body onload=\" parent.document.getElementById('ipollid').value='" . $pollid . "'; " . $ibit . " \"></body></html>";
  exit;
}

$okpollhtml='<div id=drep></div>
<h1>Favourites Polling</h1>
<h3>RJM Programming - November, 2019</h3>
<h4>Please note that on clicking Poll Me button &amp; proceeding onto a RJM Programming webpage we shall store your email address &amp; answers there.</h4>
<form action="//www.rjmprogramming.com.au/HTMLCSS/oninvalid.html" method="GET">
  Favourite anything: <input placeholder="Mandatory field" name=fa type="text" oninvalid="alert(' . "'" . 'You must fill out this ' . "'" . ' + moredetail(this.name) + ' . "'" . ' field!' . "'" . ');" value="" required></input><br><br>
  Favourite integer: <input placeholder="Mandatory field" name=fn type="number" oninvalid="alert(' . "'" . 'You must fill out this ' . "'" . ' + moredetail(this.name) + ' . "'" . ' field!' . "'" . ');" value="" step=1 required></input><br><br>
  Favourite colour: <input placeholder="Mandatory field" name=fc type="color" oninvalid="alert(' . "'" . 'You must fill out this ' . "'" . ' + moredetail(this.name) + ' . "'" . ' field!' . "'" . ');" value="" required></input><br><br>
  Favourite file: <input placeholder="Mandatory field" name=ff type="file" oninvalid="alert(' . "'" . 'You must fill out this ' . "'" . ' + moredetail(this.name) + ' . "'" . ' field!' . "'" . ');" value="" required></input><br><br>
  Favourite email: <input placeholder="Mandatory field" name=fe type="email" oninvalid="alert(' . "'" . 'You must fill out this ' . "'" . ' + moredetail(this.name) + ' . "'" . ' field!' . "'" . ');" value="" required></input><br><br>
  Favourite url: <input placeholder="Mandatory field" name=fu type="url" oninvalid="alert(' . "'" . 'You must fill out this ' . "'" . ' + moredetail(this.name) + ' . "'" . ' field!' . "'" . ');" value="" required></input><br><br>
  Favourite date: <input placeholder="Mandatory field" name=fd type="date" oninvalid="alert(' . "'" . 'You must fill out this ' . "'" . ' + moredetail(this.name) + ' . "'" . ' field!' . "'" . ');" value="" required></input><br><br>
  Favourite time: <input placeholder="Mandatory field" name=ft type="time" oninvalid="alert(' . "'" . 'You must fill out this ' . "'" . ' + moredetail(this.name) + ' . "'" . ' field!' . "'" . ');" value="" required></input><br><br>
  Favourite month: <input placeholder="Mandatory field" name=fm type="month" oninvalid="alert(' . "'" . 'You must fill out this ' . "'" . ' + moredetail(this.name) + ' . "'" . ' field!' . "'" . ');" value="" required></input><br><br>
<input type="submit" value="Poll Me" style="background-color:yellow;">
</form>
';

$sleepcode='function doubleAfter2Seconds(x) {
  return new Promise(resolve => {
    setTimeout(() => {
      resolve(x * 2);
    }, 2000);
  });
}

async function addAsync(x) {
  const a = await doubleAfter2Seconds(10);
  const b = await doubleAfter2Seconds(20);
  const c = await doubleAfter2Seconds(30);
  return x + a + b + c;
}
'; // thanks to https://stackoverflow.com/questions/17883692/how-to-set-time-delay-in-javascript

//function hex2dec
//returns an associative array (keys: R,G,B) from a hex html code (e.g. #3FE5AA)
function hex2dec($couleur = "#000000") {
    $R = substr($couleur, 1, 2);
    $rouge = hexdec($R);
    $V = substr($couleur, 3, 2);
    $vert = hexdec($V);
    $B = substr($couleur, 5, 2);
    $bleu = hexdec($B);
    $tbl_couleur = array();
    $tbl_couleur['R']=$rouge;
    $tbl_couleur['G']=$vert;
    $tbl_couleur['B']=$bleu;
    return $tbl_couleur;
}

//conversion pixel -> millimeter in 72 dpi
function px2mm($px) {
    return $px*25.4/72;
}

function txtentities($html) {
    $trans = get_html_translation_table(HTML_ENTITIES);
    $trans = array_flip($trans);
    return strtr($html, $trans);
}
////////////////////////////////////

class PDF extends FPDF {
//variables of html parser
protected $B;
protected $I;
protected $U;
protected $HREF;
protected $fontList;
protected $issetfont;
protected $issetcolor;

public $canvascmds;
public $numi;

function __construct($orientation='P', $unit='mm', $format='A4') {
    //Call parent constructor
    parent::__construct($orientation,$unit,$format);

    //Initialization
    $this->B=0;
    $this->I=0;
    $this->U=0;
    $this->HREF='';

    $this->canvascmds=['elem.style.display="block";'];
    $this->numi=0;

    $this->tableborder=0;
    $this->tdbegin=false;
    $this->tdwidth=0;
    $this->tdheight=0;
    $this->tdalign="L";
    $this->tdbgcolor=false;

    $this->oldx=0;
    $this->oldy=0;

    $this->fontlist=array("arial","times","courier","helvetica","symbol");
    $this->issetfont=false;
    $this->issetcolor=false;
}

//////////////////////////////////////
//html parser

function WriteHTML($html) {
    $html=strip_tags($html,"<b><u><i><a><img><p><br><strong><em><font><tr><blockquote><hr><td><tr><table><sup>"); //remove all unsupported tags
    $html=str_replace("\n",'',$html); //replace carriage returns with spaces
    $html=str_replace("\t",'',$html); //replace carriage returns with spaces
    $a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE); //explode the string
    foreach($a as $i=>$e) 
    {
        if($i%2==0) 
        {
            //Text
            if($this->HREF)
                $this->PutLink($this->HREF,$e);
            elseif($this->tdbegin) {
                if(trim($e)!='' && $e!="&nbsp;") {
                                     
            $this->canvascmds[sizeof($this->canvascmds)]='context.beginPath();';
            $this->canvascmds[sizeof($this->canvascmds)]='context.strokeStyle="#000000";';
            $this->canvascmds[sizeof($this->canvascmds)]='context.lineWidth=1;'; 
            $this->canvascmds[sizeof($this->canvascmds)]='context.rect(' . round($this->GetX()) . ',' . round($this->GetY()) . ',' . round($this->tdwidth) . ',' . round($this->tdheight) . ');';
            $this->canvascmds[sizeof($this->canvascmds)]='context.stroke();';
            $this->canvascmds[sizeof($this->canvascmds)]='context.strokeText("'. preg_replace('/[\x00-\x1F\x7F]/', '', str_replace("\r",'" + String.fromCharCode(10) + "',str_replace("\n",'" + String.fromCharCode(10) + "',str_replace("\r\n",'" + String.fromCharCode(10) + "',$e)))) . '",' . round($this->GetX()) . ',' . (round($this->GetY()) + round($this->tdheight) / 2) . ');';

                    $this->Cell($this->tdwidth,$this->tdheight,$e,$this->tableborder,'',$this->tdalign,$this->tdbgcolor);
                }
                elseif($e=="&nbsp;") {
                                     
            $this->canvascmds[sizeof($this->canvascmds)]='context.beginPath();';
            $this->canvascmds[sizeof($this->canvascmds)]='context.strokeStyle="#000000";';
            $this->canvascmds[sizeof($this->canvascmds)]='context.lineWidth=1;'; 
            $this->canvascmds[sizeof($this->canvascmds)]='context.rect(' . round($this->GetX()) . ',' . round($this->GetY()) . ',' . round($this->tdwidth) . ',' . round($this->tdheight) . ');';
            $this->canvascmds[sizeof($this->canvascmds)]='context.stroke();';

                    $this->Cell($this->tdwidth,$this->tdheight,'',$this->tableborder,'',$this->tdalign,$this->tdbgcolor);
                }
            }
            else {
                $this->canvascmds[sizeof($this->canvascmds)]='context.strokeText("'. preg_replace('/[\x00-\x1F\x7F]/', '', str_replace("\r",'" + String.fromCharCode(10) + "',str_replace("\n",'" + String.fromCharCode(10) + "',str_replace("\r\n",'" + String.fromCharCode(10) + "',stripslashes(txtentities($e)))))) . '",' . round($this->GetX()) . ',' . (round($this->GetY()) + round($this->tdheight) / 2) . ');';

                $this->Write(5,stripslashes(txtentities($e)));
            }
        }
        else
        {
            //Tag
            if($e[0]=='/')
                $this->CloseTag(strtoupper(substr($e,1)));
            else
            {
                //Extract attributes
                $a2=explode(' ',$e);
                $tag=strtoupper(array_shift($a2));
                $attr=array();
                foreach($a2 as $v)
                {
                    if(preg_match('/([^=]*)=["\']?([^"\']*)/',$v,$a3))
                        $attr[strtoupper($a3[1])]=$a3[2];
                }
                $this->OpenTag($tag,$attr);
            }
        }
    }
}

function OpenTag($tag, $attr) {
    //Opening tag
    switch($tag){

        case 'SUP':
            if( !empty($attr['SUP']) ) {    
                //Set current font to 6pt     
                $this->SetFont('','',6);
                //Start 125cm plus width of cell to the right of left margin         
                //Superscript "1" 
                                     
            $this->canvascmds[sizeof($this->canvascmds)]='context.beginPath();';
            $this->canvascmds[sizeof($this->canvascmds)]='context.strokeStyle="#000000";';
            $this->canvascmds[sizeof($this->canvascmds)]='context.lineWidth=1;'; 
            $this->canvascmds[sizeof($this->canvascmds)]='context.rect(' . round($this->GetX()) . ',' . round($this->GetY()) . ',2,2);';
            $this->canvascmds[sizeof($this->canvascmds)]='context.stroke();';
            $this->canvascmds[sizeof($this->canvascmds)]='context.strokeText("'. $attr['SUP'] . '",' . round($this->GetX()) . ',' . round($this->GetY()) . ');';

                $this->Cell(2,2,$attr['SUP'],0,0,'L');
            }
            break;

        case 'TABLE': // TABLE-BEGIN
            if( !empty($attr['BORDER']) ) $this->tableborder=$attr['BORDER'];
            else $this->tableborder=0;
            break;
        case 'TR': //TR-BEGIN
            break;
        case 'TD': // TD-BEGIN
            if( !empty($attr['WIDTH']) ) $this->tdwidth=($attr['WIDTH']/4);
            else $this->tdwidth=40; // Set to your own width if you need bigger fixed cells
            if( !empty($attr['HEIGHT']) ) $this->tdheight=($attr['HEIGHT']/6);
            else $this->tdheight=6; // Set to your own height if you need bigger fixed cells
            if( !empty($attr['ALIGN']) ) {
                $align=$attr['ALIGN'];        
                if($align=='LEFT') $this->tdalign='L';
                if($align=='CENTER') $this->tdalign='C';
                if($align=='RIGHT') $this->tdalign='R';
            }
            else $this->tdalign='L'; // Set to your own
            if( !empty($attr['BGCOLOR']) ) {
                $coul=hex2dec($attr['BGCOLOR']);
                    $this->SetFillColor($coul['R'],$coul['G'],$coul['B']);
                    $this->tdbgcolor=true;
                }
            $this->tdbegin=true;
            break;

        case 'HR':
            if( !empty($attr['WIDTH']) )
                $Width = $attr['WIDTH'];
            else
                $Width = $this->w - $this->lMargin-$this->rMargin;
            $x = $this->GetX();
            $y = $this->GetY();
            $this->SetLineWidth(0.2);
                
            $this->canvascmds[sizeof($this->canvascmds)]='context.beginPath();';
            $this->canvascmds[sizeof($this->canvascmds)]='context.strokeStyle="#000000";';
            $this->canvascmds[sizeof($this->canvascmds)]='context.lineWidth=2;'; 
            $this->canvascmds[sizeof($this->canvascmds)]='context.moveTo(' . round($x) . ',' . round($y) . ');';
            $this->canvascmds[sizeof($this->canvascmds)]='context.lineTo(' . round(($x+$Width)) . ',' . round($y) . ');';
            $this->canvascmds[sizeof($this->canvascmds)]='context.stroke();';

            $this->Line($x,$y,$x+$Width,$y);
            $this->SetLineWidth(0.2);
            $this->Ln(1);
            break;
        case 'STRONG':
            $this->SetStyle('B',true);
            break;
        case 'EM':
            $this->SetStyle('I',true);
            break;
        case 'B':
        case 'I':
        case 'U':
            $this->SetStyle($tag,true);
            break;
        case 'A':
            $this->HREF=$attr['HREF'];
            break;
        case 'IMG':
            if(isset($attr['SRC']) && (isset($attr['WIDTH']) || isset($attr['HEIGHT']))) {
                if(!isset($attr['WIDTH']))
                    $attr['WIDTH'] = 0;
                if(!isset($attr['HEIGHT']))
                    $attr['HEIGHT'] = 0;
                
            $this->canvascmds[sizeof($this->canvascmds)]='x[' . $this->numi . ']=' . round($this->GetX()) . ';';
            $this->canvascmds[sizeof($this->canvascmds)]='y[' . $this->numi . ']=' . round($this->GetY()) . ';';
            $this->canvascmds[sizeof($this->canvascmds)]='w[' . $this->numi . ']=' . round(px2mm($attr['WIDTH'])) . ';';
            $this->canvascmds[sizeof($this->canvascmds)]='h[' . $this->numi . ']=' . round(px2mm($attr['HEIGHT'])) . ';';
            $this->canvascmds[sizeof($this->canvascmds)]='aimg[' . $this->numi . ']="' . $attr['SRC'] . '";';
            if ($this->numi == 0) { $this->canvascmds[sizeof($this->canvascmds)]='ielem.src="' . $attr['SRC'] . '";'; }
            $this->numi++;
            //$this->canvascmds[sizeof($this->canvascmds)]='while (h >= 0) { addAsync(10).then((sum) => {  console.log(sum); });  } ';
            $this->canvascmds[sizeof($this->canvascmds)]='if (1 == 3) { context.drawImage(ielem,' . round($this->GetX()) . ',' . round($this->GetY()) . round(px2mm($attr['WIDTH'])) . ',' . round(px2mm($attr['HEIGHT'])) . '); } ';

                $this->Image($attr['SRC'], $this->GetX(), $this->GetY(), px2mm($attr['WIDTH']), px2mm($attr['HEIGHT']));
           }
            break;
        case 'BLOCKQUOTE':
        case 'BR':
            $this->Ln(5);
            break;
        case 'P':
            $this->Ln(10);
            break;
        case 'FONT':
            if (isset($attr['COLOR']) && $attr['COLOR']!='') {
                $coul=hex2dec($attr['COLOR']);
                $this->SetTextColor($coul['R'],$coul['G'],$coul['B']);
                $this->issetcolor=true;
            }
            if (isset($attr['FACE']) && in_array(strtolower($attr['FACE']), $this->fontlist)) {
                $this->SetFont(strtolower($attr['FACE']));
                $this->issetfont=true;
            }
            if (isset($attr['FACE']) && in_array(strtolower($attr['FACE']), $this->fontlist) && isset($attr['SIZE']) && $attr['SIZE']!='') {
                $this->SetFont(strtolower($attr['FACE']),'',$attr['SIZE']);
                $this->issetfont=true;
            }
            break;
    }
}

function CloseTag($tag) {
    //Closing tag
    if($tag=='SUP') {
    }

    if($tag=='TD') { // TD-END
        $this->tdbegin=false;
        $this->tdwidth=0;
        $this->tdheight=0;
        $this->tdalign="L";
        $this->tdbgcolor=false;
    }
    if($tag=='TR') { // TR-END
        $this->Ln();
    }
    if($tag=='TABLE') { // TABLE-END
        $this->tableborder=0;
    }

    if($tag=='STRONG')
        $tag='B';
    if($tag=='EM')
        $tag='I';
    if($tag=='B' || $tag=='I' || $tag=='U')
        $this->SetStyle($tag,false);
    if($tag=='A')
        $this->HREF='';
    if($tag=='FONT'){
        if ($this->issetcolor==true) {
            $this->SetTextColor(0);
        }
        if ($this->issetfont) {
            $this->SetFont('arial');
            $this->issetfont=false;
        }
    }
}

function SetStyle($tag, $enable) {
    //Modify style and select corresponding font
    $this->$tag+=($enable ? 1 : -1);
    $style='';
    foreach(array('B','I','U') as $s) {
        if($this->$s>0)
            $style.=$s;
    }
    $this->SetFont('',$style);
}

function PutLink($URL, $txt) {
    //Put a hyperlink
    $this->SetTextColor(0,0,255);
    $this->SetStyle('U',true);
    
    $this->canvascmds[sizeof($this->canvascmds)]='context.strokeText("'. preg_replace('/[\x00-\x1F\x7F]/', '', str_replace("\r",'" + String.fromCharCode(10) + "',str_replace("\n",'" + String.fromCharCode(10) + "',str_replace("\r\n",'" + String.fromCharCode(10) + "',$txt)))) . '",' . round($this->GetX()) . ',' . (round($this->GetY()) + round($this->tdheight) / 2) . ');';

    $this->Write(5,$txt,$URL);
    $this->SetStyle('U',false);
    $this->SetTextColor(0);
}

} //end of class

  function addtotable($imgurl) {
    global $thtml, $pdf, $mw, $mh;
    $prefix="";
    if (strpos(("~" . strtolower($imgurl)), "~http") === false) {
    if (!file_exists($prefix . $imgurl)) {
      if (isset($_GET['rp'])) {
        if (file_exists(str_replace('+',' ',urldecode($_GET['rp'])) . $imgurl)) {
          $prefix=str_replace('+',' ',urldecode($_GET['rp']));
        } else if (file_exists("../" . str_replace('+',' ',urldecode($_GET['rp'])) . $imgurl)) {
          $prefix="../" . str_replace('+',' ',urldecode($_GET['rp']));
        }
      } else if (isset($_POST['rp'])) {
        if (file_exists(str_replace('+',' ',urldecode($_POST['rp'])) . $imgurl)) {
          $prefix=str_replace('+',' ',urldecode($_POST['rp']));
        } else if (file_exists("../" . str_replace('+',' ',urldecode($_POST['rp'])) . $imgurl)) {
          $prefix="../" . str_replace('+',' ',urldecode($_POST['rp']));
        }
      } else if (file_exists("../" . $imgurl)) {
        $prefix="../";
      }
    }
    }
    list($width, $height, $type, $attr) = getimagesize($prefix . $imgurl);
    if (!$pdf) { if ($width >= $height) {  $pdf=new PDF('L'); $mw=MAX_L_WIDTH;  $mh=MAX_L_HEIGHT;  } else {  $pdf=new PDF('P');   $mw=MAX_P_WIDTH;  $mh=MAX_P_HEIGHT;   }  }
    if ($mw < $width && $mh >= $height) { $width=0; } else if ($mw >= $width && $mh < $height) {  $height=0; } else if ($mw < $width && $mh < $height) { $width=-$mw;  $height=-$mh;   }
    if ($thtml == "") {
      $pdf->AddPage();
      $pdf->SetFont('Arial','',12);
      if ($width == 0) {
      //echo "h";
      //exit;
      $thtml.='<img height="' . $height . '" src="' . $prefix . $imgurl . '"></img>';
      } else if ($height == 0) {
      //echo "w";
      //exit;
      $thtml.='<img width="' . $width . '" src="' . $prefix . $imgurl . '"></img>';
      } else if ($height < 0 && $width < 0) {
      //echo "hw";
      //exit;
      $thtml.='<img height="' . $height . '" width="' . $width . '" src="' . $prefix . $imgurl . '"></img>';
      } else {
      //echo "table " . $width . " vs " . $mw . " and " . $height . " vs " . $mh;
      //exit;
      $thtml.='<table border="1" width="' . $width . '" height="' . $height . '"><tr><td width="' . $width . '" height="' . $height . '"><img width="' . $width . '" height="' . $height . '" src="' . $prefix . $imgurl . '"></img></td></tr></table>';
      }
      $pdf->WriteHTML($thtml);   // $thtml is some HTML table code collected earlier on
      $thtml=' ';
    } else {
      $pdf->AddPage();
      $pdf->SetFont('Arial','',12);
      if ($width == 0) {
      $thtml.='<img height="' . $height . '" src="' . $prefix . $imgurl . '"></img>';
      } else if ($height == 0) {
      $thtml.='<img width="' . $width . '" src="' . $prefix . $imgurl . '"></img>';
      } else if ($height < 0 && $width < 0) {
      $thtml.='<img height="' . $height . '" width="' . $width . '" src="' . $prefix . $imgurl . '"></img>';
      } else {
      $thtml='<br><br><table border="1" width="' . $width . '" height="' . $height . '"><tr><td width="' . $width . '" height="' . $height . '"><img width="' . $width . '" height="' . $height . '" src="' . $prefix . $imgurl . '"></img></td></tr></table>';
      }
      $pdf->WriteHTML($thtml);   // $thtml is some HTML table code collected earlier on
      $thtml=' ';
    }
  }

  $none='none';
  if (isset($_GET['viaemail'])) { $none='inline-block'; }
  $pdf=null;
  $trow='<tr><td width="200" height="30">cell 1</td><td width="200" height="30" bgcolor="#D0D0FF">cell 2</td></tr>';
  $thtml='<table border="1"></table>';
  $mw=MAX_P_WIDTH;
  $mh=MAX_P_HEIGHT;
  
  if (isset($_POST['formtable'])) {
    $thtml=str_replace('+', ' ', urldecode($_POST['formtable']));
  } else if (isset($_GET['formtable'])) {
    $thtml=str_replace('+', ' ', urldecode($_GET['formtable']));
  } else if (isset($_POST['slideshowlist'])) {
    $thtml='';
    $slideshowlist=explode(",", str_replace('+', ' ', urldecode($_POST['slideshowlist'])));
    for ($ii=0; $ii<sizeof($slideshowlist); $ii++) {
     if ($slideshowlist[$ii] != "") { addtotable($slideshowlist[$ii]); }
    }
  } else if (isset($_GET['slideshowlist'])) {
    $thtml='';
    $slideshowlist=explode(",", str_replace('+', ' ', urldecode($_GET['slideshowlist'])));
    for ($ii=0; $ii<sizeof($slideshowlist); $ii++) {
     if ($slideshowlist[$ii] != "") { addtotable($slideshowlist[$ii]); }
    }
  } else {
    $thtml='<table border="1" height="400"><tr><td width="200" height="400">cell 1</td><td width="200" height="400" bgcolor="#D0D0FF"><img width="200" height="200" src="./one.jpg"></img></td></tr></table>';
    $otherbuttons='<input onclick="woit();" style="background-color:lightblue;" value="Preview HTML Rendering" type=button></input>&nbsp;<input id=inlinei onclick="emailit();" style="background-color:lightblue;" value="Email HTML Inline" type=button></input>&nbsp;<input onclick="pollit();" style="background-color:lightblue;" value="Email Inline Poll Report" type=button></input>&nbsp;<input onclick="collateit();" style="background-color:lightblue;" value="Poll Report" type=button></input>&nbsp;';
    $ebutton='<form target=iemail data-target=_blank method=POST data-method=GET action=../HTMLCSS/emailhtml.php style=display:none;><input type=hidden id=eto name=eto value=""></input><input type=hidden id=esubject name=esubject value="Email HTML Inline"></input><textarea style=display:none; id=ebody name=ebody value=""></textarea><input type=hidden name=inline value=""></input><input type=submit id=esubmit style=display:none; value=Email></input></form><iframe name=iemail id=iemail style=display:none; src=></iframe>&nbsp;';
    $thtml.='<br><br><table border="1" height="400"><tr><td width="200" height="400">cell 1</td><td width="200" height="400" bgcolor="#D0D0FF"><img width="200" height="200" src="./one.jpg"></img></td></tr></table>';
    $jscr="<sc" . "ript type='text/javascript'>
      var elem=null, context=null;
      var pollerid=" . $pollid . ";
      var tois='';
      var pollexec=false;
      var wo=null;
      var url=document.URL.split('#')[0].split('?')[0];

 function relative_to_absolute(inth) {
    var huhs, posthuhs, ii, m, delimis=\" \";
    var uubits=url.split(\"?\");

    if (url == \"\") return inth;

    if (uubits[0].indexOf(\"/\") != -1) {
      var uuubits=uubits[0].split(\"/\");
      if (uuubits[eval(uuubits.length - 1)] != \"\") {
        if (uuubits[eval(uuubits.length - 1)].indexOf(\".\") != -1) {
          uubits[0] = uubits[0].replace(\"/\" + uuubits[eval(uuubits.length - 1)], \"/\");
        } else {
          uubits[0] += \"/\";
        }
      }
    }

    var uudirname=uubits[0];
    var outth = inth;
    var ideas = new Array(\" action='\", ' action=\"', \" Action='\", ' Action=\"', \" ACTION='\", ' ACTION=\"', \" action=\", \" Action=\", \" ACTION=\", \" href='\", ' href=\"', \" Href='\", ' Href=\"', \" HREF='\", ' HREF=\"', \" href=\", \" Href=\", \" HREF=\", \" src='\", ' src=\"', \" Src='\", ' Src=\"', \" SRC='\", ' SRC=\"', \" src=\", \" Src=\", \" SRC=\");

    if (uudirname != \"\" && url != \"\") {
     for (m=0; m<ideas.length; m++) {
      huhs = inth.split(ideas[m]);
      if (huhs.length > 1) {
        for (ii=eval(huhs.length - 1); ii>=1; ii--) {
          delimis=ideas[m].substring(eval(ideas[m].length - 1), eval(ideas[m].length));
          if (delimis == \"=\") delimis=\" \";
          posthuhs=huhs[ii].trim().replace(\">\",\" \").replace(/mailto:/g, \"http:\").replace(/javascript:none;/g, \"http:\").split(delimis);
          if (posthuhs[0].length > 0) {
          if (posthuhs[0].substring(0,1) == \"#\" || posthuhs[0].substring(0,4).toLowerCase().replace(/file/g, \"http\").toLowerCase() == \"http\") {
              outth = outth;
          } else if (posthuhs[0].substring(0,1) != \"/\" && posthuhs[0].substring(0,1) != \"'\" && posthuhs[0].substring(0,1) != '\"') {
              while (outth.indexOf(posthuhs[0]) != -1) {
                outth=outth.replace(posthuhs[0], \"youwill-never-ever-findthis\");
              }
              outth=outth.replace(/youwill-never-ever-findthis/g, uudirname + posthuhs[0]).replace(/\/\.\//g, '/');
          } else if (posthuhs[0].substring(1,2) != \"/\" && posthuhs[0].substring(0,1) != \"'\" && posthuhs[0].substring(0,1) != '\"') {
              while (outth.indexOf(posthuhs[0]) != -1) {
                outth=outth.replace(posthuhs[0], \"youwill-never-ever-findthis\");
              }
              outth=outth.replace(/youwill-never-ever-findthis/g, uudirname.substring(0, eval(uudirname.length - 1)) + posthuhs[0]).replace(/\/\.\//g, '/');
          }
          }
        }
      }
     }
    }

    return outth.replace(/\/\.\//g, '/');
 }

      function woit() {
         if (wo) { wo.close(); wo=null; }
         wo=window.open('','_blank','top=50,left=50,width=500,height=500');
         document.getElementById('formtable').innerHTML=relative_to_absolute(document.getElementById('formtable').value.replace(/\</g,'&lt;').replace(/\>/g,'&gt;'));        
         document.getElementById('formtable').value=document.getElementById('formtable').innerHTML.replace(/\&lt\;/g,'<').replace(/\&gt\;/g,'>');
         wo.document.write('<body><table><tr><td>' + relative_to_absolute(document.getElementById('formtable').value) + '</td><td> ... is the look of ...</td><td><form method=POST action=' + document.URL.split('#')[0].split('?')[0] + '>' + document.getElementById('formtable').outerHTML + '<br><br><input id=bsubmit style=\"background-color:yellow;\" value=\"HTML Above to PDF\" type=submit></input>&nbsp;<input id=bbsubmit style=\"background-color:orange;\" value=\"HTML Above to PDF and Canvas\" name=both type=submit></input>&nbsp;<input id=bbcsubmit style=\"background-color:lightgray;\" value=\"HTML Above to Canvas\" name=justc type=submit></input></form></td></tr></table><input style=\"position:absolute;top:-200px;left:-200px;\" value=\"\" type=\"text\"></input></body>');
      }
      
      function domore(iois) {
         if (pollexec) {
          pollexec=false;
          document.getElementById('ebody').value='<body><table><tr><td>' + relative_to_absolute(document.getElementById('formtable').value.replace('</f' + 'orm>', document.getElementById('ipollid').outerHTML.replace(' id=',' name=') + '</f' + 'orm>').replace('//www.rjmprogramming.com.au/HTMLCSS/oninvalid.html',document.URL.split('?')[0].split('#')[0])) + '</td><td> ... <a target=_blank title=\"Created via ...\" href=\"' + document.URL.split('#')[0].split('?')[0] + '?viaemail=y' + '\">Courtesy of RJM Programming<br><br><br><img alt=\"RJM Programming Logo\" src=' + '\"' + document.getElementById('imgpoll').src + '\"' + '></img><br><br>Software Need Not Be Hard!</a></td></tr></table></body>';
          document.getElementById('esubmit').click();
          alert('Email sent to ' + tois.replace('?',''));
          //document.getElementById('bsubmit').click();           
         }
      }
      
      function emailit() {
         if (tois.indexOf('?') != -1 && tois.indexOf('@') != -1) {
         tois=tois.replace('?','');
         } else {
         tois='';
         }
         if (pollexec) { 
         if (tois.indexOf('@') == -1) { tois='?'; }
         while (tois.indexOf('?') != -1) {
         tois=prompt('Email to?  Please note that as a new poller we shall store your email address as an official Poller at this webpage.  Add ? to see what you have already entered regarding this email in the past.', '');
         if (tois == null) { tois=''; }
         if (tois.indexOf('?') != -1) {
         document.getElementById('jfpoll').src=document.URL.split('#')[0].split('?')[0] + '?pollerquery=' + encodeURIComponent(tois.replace('?','').toLowerCase()); 
         setTimeout(emailit,5000);
         return;
         }
         }
         } else {
         tois=prompt('Email to?', '');
         }
         if (tois == null) { tois=''; }
         if (tois.indexOf('@') != -1) {
         document.getElementById('formtable').innerHTML=relative_to_absolute(document.getElementById('formtable').value.replace(/\</g,'&lt;').replace(/\>/g,'&gt;'));        
         document.getElementById('formtable').value=document.getElementById('formtable').innerHTML.replace(/\&lt\;/g,'<').replace(/\&gt\;/g,'>');
         document.getElementById('eto').value=tois.replace('?','');
         if (pollexec) { 
          document.getElementById('ifpoll').src=document.URL.split('#')[0].split('?')[0] + '?polleremail=' + encodeURIComponent(tois.replace('?','').toLowerCase()); 
         } else {
          var ebod='<body><table><tr><td>';
          ebod+=relative_to_absolute(document.getElementById('formtable').value);
          ebod+='</td><td> ... <a target=_blank title=\"Created via ...\" href=\"' + document.URL.split('#')[0].split('?')[0] + '\" >is the look of</a> ...</td><td><form method=POST action=' + document.URL.split('#')[0].split('?')[0] + '>';
          ebod+=document.getElementById('formtable').outerHTML;
          ebod+='<br><br><input id=bsubmit style=\"background-color:yellow;\" value=\"HTML Above to PDF\" type=submit></input>&nbsp;<input id=bbsubmit style=\"background-color:orange;\" value=\"HTML Above to PDF and Canvas\" name=both type=submit></input>&nbsp;<input id=bbcsubmit style=\"background-color:lightgray;\" value=\"HTML Above to Canvas\" name=justc type=submit></input></form></td></tr></table><input style=\"position:absolute;top:-200px;left:-200px;\" value=\"\" type=\"text\"></input></body>';
          document.getElementById('ebody').value=ebod; //'<body><table><tr><td>' + relative_to_absolute(document.getElementById('formtable').value) + '</td><td> ... <a target=_blank title=\"Created via ...\" href=\"' + document.URL.split('#')[0].split('?')[0] + '\" >is the look of</a> ...</td><td><form method=POST action=' + document.URL.split('#')[0].split('?')[0] + '>' + document.getElementById('formtable').outerHTML + '<br><br><input id=bsubmit style=\"background-color:yellow;\" value=\"HTML Above to PDF\" type=submit></input>&nbsp;<input id=bbsubmit style=\"background-color:orange;\" value=\"HTML Above to PDF and Canvas\" name=both type=submit></input>&nbsp;<input id=bbcsubmit style=\"background-color:lightgray;\" value=\"HTML Above to Canvas\" name=justc type=submit></input></form></td></tr></table><input style=\"position:absolute;top:-200px;left:-200px;\" value=\"\" type=\"text\"></input></body>';
          document.getElementById('esubmit').click();
          alert('Email sent to ' + tois.replace('?',''));
          //document.getElementById('bsubmit').click();
         }
         }
      }

      function collateit() {
         window.open(document.URL.split('?')[0].split('#')[0] + '?collate=' + Math.floor(Math.random() * 18765432), '_blank', 'top=80,left=80,width=500,height=500');
      }

      function pollit() {
         document.getElementById('formtable').innerHTML=document.getElementById('tapoll').innerHTML;
         document.getElementById('formtable').value=document.getElementById('tapoll').value;
         pollexec=true;
         setTimeout(emailit,500);
      }
    </scr" . "ipt>
    ";
    echo '<!doctype html><html><head>' . $jscr . '</head><body style="background-color:lightgreen;"><h1>PDF Slideshow and Form Creation Helper</h1><h3><img onclick=window.open("//www.rjmprogramming.com.au","_blank"); title="Software Need Not Be Hard!" alt="RJM Programming Logo" id=imgpoll style=display:' . $none . '; src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBARXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAZqADAAQAAAABAAAATQAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/+IH6ElDQ19QUk9GSUxFAAEBAAAH2GFwcGwCIAAAbW50clJHQiBYWVogB9kAAgAZAAsAGgALYWNzcEFQUEwAAAAAYXBwbAAAAAAAAAAAAAAAAAAAAAAAAPbWAAEAAAAA0y1hcHBsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALZGVzYwAAAQgAAABvZHNjbQAAAXgAAAWcY3BydAAABxQAAAA4d3RwdAAAB0wAAAAUclhZWgAAB2AAAAAUZ1hZWgAAB3QAAAAUYlhZWgAAB4gAAAAUclRSQwAAB5wAAAAOY2hhZAAAB6wAAAAsYlRSQwAAB5wAAAAOZ1RSQwAAB5wAAAAOZGVzYwAAAAAAAAAUR2VuZXJpYyBSR0IgUHJvZmlsZQAAAAAAAAAAAAAAFEdlbmVyaWMgUkdCI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Hxn/tvX9IPiGKbX1KWjt/vUf/mQ8p07Nq+z7f8A26/L7jlvhT8B/EHwL/aF8K/Fr4IfE678B2fxG+IXhDRP2gvhhL4cGs/DP416P4h1fTPDc3iO/wDDia9pCeEfjLottPav4f8Ai9oEv9pz2tjFoXjrRPHXhxLLSLD4riChhMTUnmuCw7y/GfFjOWoq2Gx8bW5q9CNLD8uKi+XlxcJxm43hWjiF7P2XRSk9KcvejtHS0oeju7rvFt+TjufvadEtASPMueDj78P/AMbr5BY2u0ny0tf7sv8A5evy+41fKm1Z6Pv/AMP+f3if2Jaf37n/AL7h/wDjdH12v/LS/wDAJf8Ay8Xu9n94f2Jaf37n/vuH/wCN0fXa/wDLS/8AAJf/AC8Pd7P7w/sS0/v3P/fcP/xuj67X/lpf+AS/+Xh7vZ/eH9iWn9+5/wC+4f8A43R9dr/y0v8AwCX/AMvD3ez+8P7EtP79z/33D/8AG6Prtf8Alpf+AS/+Xh7vZ/ebei6bBE9xDE8oaVY5C8hR1CwllKBFVCS5nB37wFCEbW3ZTz8fiKk4051FC0XKKjBOLbmk78zqz0Sg1a2vNe65Upa0kndK628/1j+f3X97/9k="></img>&nbsp;RJM Programming - October, 2019</h3><h4>Thanks to <a target=_blank title=Fpdf href="http://www.fpdf.org/">Fpdf</a></h4><form method=POST action=./form_creator.php><textarea style="background-color:pink;width:90%;" name=formtable id=formtable rows=20>' . $thtml . '</textarea><br><br>' . $otherbuttons . '<br><br><input id=bsubmit style="background-color:yellow;" value="HTML Above to PDF" type=submit></input>&nbsp;<input id=bbsubmit style="background-color:orange;" value="HTML Above to PDF and Canvas" name=both type=submit></input>&nbsp;<input id=bbcsubmit style="background-color:lightgray;" value="HTML Above to Canvas" name=justc type=submit></input></form>' . $ebutton . '<input style="position:absolute;top:-200px;left:-200px;" value="" type="text"></input><textarea id=tapoll style=display:none;>' . $okpollhtml . '</textarea><input type=hidden id=ipollid value=' . $pollid . '></input><iframe onload=domore(this); style=display:none; id=ifpoll src=></iframe><iframe style=display:none; id=jfpoll src=></iframe><br><canvas style=display:none; width=100% height=100vh id=canvas></canvas><scr' . 'ipt type="text/javascript"> elem=document.getElementById("canvas"); context=elem.getContext("2d"); </scr' . 'ipt></body></html>';
    exit;
  }

  
  foreach( $_GET as $name=>$val ) {
  }
  
  foreach( $_POST as $name=>$val ) {
  }
  
 if (!$pdf) {
  $pdf=new PDF();
 }
 if ($pdf && trim($thtml) != "") {
  $pdf->AddPage();
  $pdf->SetFont('Arial','',12);
  $pdf->WriteHTML($thtml);   // $thtml is some HTML table code collected earlier on
 }
 if ($pdf) {
  if (isset($_POST['both']) || isset($_GET['both'])) {
  $canvh="<html><head><scr" . "ipt type='text/javascript'> var elem=null,context=null,x=[],y=[],w=[],h=[],aimg=[],iimg=0; " . $sleepcode . " function di(iois) {  if (iois.src != '') { context.drawImage(ielem,x[iimg],y[iimg],w[iimg],h[iimg]); iimg++; if (aimg.length > iimg) { iois.src=aimg[iimg] + '?xx=' + iimg; }  }  } function docanvas() { elem=document.getElementById('canvas'); ielem=document.getElementById('him'); context=elem.getContext('2d'); context.font='8px Arial';   } </scr" . "ipt></head><body onload=\"  window.open('form_creator.pdf','_blank','left=50,top=50,width=695,height=942'); docanvas(); \"><canvas style='border:1px solid red;width:595px;width:842px;' width=" . (595 / 2.54) . " height=" . (842 / 2.54) . " id=canvas></canvas><br><img onload=di(this); id=him style=display:none; src=></img></body></html>";
  for ($jj=0; $jj<sizeof($pdf->canvascmds); $jj++) {
    $canvh=str_replace("} <"," " . $pdf->canvascmds[$jj] . " \n} <", $canvh);
  }
  $pdfcont=$pdf->Output('form_creator.pdf','F');
  echo $canvh; 
  } else if (isset($_POST['justc']) || isset($_GET['justc'])) {
  $canvh="<html><head><scr" . "ipt type='text/javascript'> var elem=null,context=null,x=[],y=[],w=[],h=[],aimg=[],iimg=0; " . $sleepcode . " function di(iois) {  if (iois.src != '') { context.drawImage(ielem,x[iimg],y[iimg],w[iimg],h[iimg]); iimg++; if (aimg.length > iimg) { iois.src=aimg[iimg] + '?xx=' + iimg; }  }  } function docanvas() { elem=document.getElementById('canvas'); ielem=document.getElementById('him'); context=elem.getContext('2d'); context.font='8px Arial';   } </scr" . "ipt></head><body onload=\"  docanvas(); \"><canvas style='border:1px solid red;width:595px;width:842px;' width=" . (595 / 2.54) . " height=" . (842 / 2.54) . " id=canvas></canvas><br><img onload=di(this); id=him style=display:none; src=></img></body></html>";
  for ($jj=0; $jj<sizeof($pdf->canvascmds); $jj++) {
    $canvh=str_replace("} <"," " . $pdf->canvascmds[$jj] . " \n} <", $canvh);
  }
  //$pdfcont=$pdf->Output('form_creator.pdf','F');
  echo $canvh; 
  } else {
  header('Content-type: application/pdf'); 
  $pdf->Output();
  }
 }
 exit;

?>
