Want more features on Pastebin? Sign Up, it's FREE!
Guest

testing6.php

By: a guest on Jan 19th, 2013  |  syntax: PHP  |  size: 1.42 KB  |  views: 108  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. require('fpdf.php');
  3. class PDF extends FPDF
  4.  
  5. {
  6. var $B;
  7. var $I;
  8. var $U;
  9. var $HREF;
  10.  
  11. function WriteHTML($user)
  12. {
  13.     // HTML parser
  14.     $user = str_replace("\n",' ',$user);
  15.     $a = preg_split('/<(.*)>/U',$user,-1,PREG_SPLIT_DELIM_CAPTURE);
  16.     foreach($a as $i=>$e)
  17.     {
  18.         if($i%2==0)
  19.         {
  20.             // Text
  21.             if($this->HREF)
  22.                 $this->PutLink($this->HREF,$e);
  23.             else
  24.                 $this->Write(5,$e);
  25.         }
  26.         else
  27.         {
  28.             // Tag
  29.             if($e[0]=='/')
  30.                 $this->CloseTag(strtoupper(substr($e,1)));
  31.             else
  32.             {
  33.                 // Extract attributes
  34.                 $a2 = explode(' ',$e);
  35.                 $tag = strtoupper(array_shift($a2));
  36.                 $attr = array();
  37.                 foreach($a2 as $v)
  38.                 {
  39.                     if(preg_match('/([^=]*)=["\']?([^"\']*)/',$v,$a3))
  40.                         $attr[strtoupper($a3[1])] = $a3[2];
  41.                 }
  42.                 $this->OpenTag($tag,$attr);
  43.             }
  44.         }
  45.     }
  46. }
  47.  
  48. }
  49.  
  50. $user = $_POST['user'];
  51.  
  52. $pdf = new PDF();
  53. $pdf->AddPage();
  54. $pdf->SetFont('Arial','B',16);
  55. $pdf->WriteHTML((string)$user);
  56. $pdf->Output();
  57. ?>
  58.  
  59. <html>
  60. <body>
  61. <form name="input" action="testing6.php" method="get">
  62. Username: <input type="text" name="user">
  63. <input type="submit" value="Submit">
  64. </form>
  65. </body>
  66. <html>
clone this paste RAW Paste Data