Output(preg_replace("/[^a-z0-9\.]/", "", strtolower($_POST['title'])).".pdf"); //echo $finalHTML; } else { echo getHTML("There was a problem uploading the file"); } } else { $html = "

Select Source .csv File

"; $html .= "
"; $html .= "
"; $html .= "Title:
"; $html .= "CSV File:
"; $html .= "Card Size:
"; $html .= "Titles in First Row:
"; $html .= ""; $html .= "
"; $html .= "
"; echo getHTML($html); } function showCards($document,$size,$titles_in_first) { global $ptsperinch,$cardwidth,$cardheight,$cardpadding; $fh = fopen($document,'r'); $cards = array(); while(($data = fgetcsv($fh,1000,",",'"'))!==FALSE){ $cards[] = array('title'=>$data[0],'text'=>$data[1]); } if($titles_in_first){ array_shift($cards); } switch($size){ case 'american-mini': $cardwidth = 40; $cardheight = 62; $cardsperrow = 4; $orientation = "P"; break; case 'european-mini': $cardwidth = 43; $cardheight = 67; $cardsperrow = 4; $orientation = "P"; break; case 'american-standard': $cardwidth = 56; $cardheight = 88; $cardsperrow = 3; $orientation = "P"; break; case 'european-standard': $cardwidth = 58; $cardheight = 91; $cardsperrow = 3; $orientation = "P"; break; case 'card-game-standard': $cardwidth = 62.5; $cardheight = 87; $cardsperrow = 3; $orientation = "P"; break; case 'square': $cardwidth = 69; $cardheight = 69; $cardsperrow = 3; $orientation = "L"; break; case 'tarot': $cardwidth = 69; $cardheight = 119; $cardsperrow = 3; $orientation = "L"; break; } $html = ''; $i=1; foreach($cards as $card){ if(($i-1)%$cardsperrow==0){ $html .= ''; } $html .= ''; if(($i)%$cardsperrow==0){ $html .= ''; } $i++; } if(($i-1)%$cardsperrow!=0){ $j = $i-1; while($j%$cardsperrow!=0){ $html .= ''; $j++; } $html .= ""; } $html .="

'.$card['title'].'

'.$card['text'].'
"; unlink($document); $pdf = new HTML2PDF($orientation,'LETTER','en'); $pdf->pdf->SetDisplayMode('fullpage'); $finalHTML = getHTML($html); $pdf->writeHTML($finalHTML); return $pdf; } function getHTML($content){ global $cardwidth, $cardheight, $cardpadding; $html = " $content "; return $html; } ?>