title: To show php variable in pdf file generated using fpdf
body: <p>I want this php  variable to be showed in pdf file . But it gives error :- Pdf file does not begin with '%Pdf-'</p>
  
  <p>A.php  it contains my form . By using post i am sending values to other printpdf.php 
  Where  printpdf.php generates a pdf file with a specific format .</p>
  
  <p>A.php</p>
  
  <pre><code> &lt;form class="mid" action="printpdf.php" method="post"&gt; 
   &lt;input type="hidden" id="cname" name="cname" value="&lt;?php echo $c_n[0]; ?&gt;"/&gt;
    &lt;input type="submit" id="but" value="Print Challan"/&gt;     
   &lt;/form&gt;
  </code></pre>
  
  <p>printpdf.php</p>
  
  <pre><code> &lt;?php
  
    $c_n = $_POST['cname'];
  
  
    require('fpdf.php');
   class PDF extends FPDF
       {
  
       function Header()
      {
         $this-&gt;Image('image.jpg',5,5,200);
         $this-&gt;Ln(20);
         }
  
       //Page footer
       function Footer()
     {
         $this-&gt;SetFont('Arial','I',8);
         $this-&gt;Image('image1.jpeg',5,275,200);
         $this-&gt;SetXY(5, 284);
         $this-&gt;Cell(0,5,'This is a system generated ',0,2,'C');
         $this-&gt;Cell(0,5,'Page '.$this-&gt;PageNo().'/{nb}',0,0,'C');
  
         }
          }
           //Instanciation of inherited class
  
         $pdf=new PDF();
         $pdf-&gt;AliasNbPages();
         $pdf-&gt;AddPage();
         $pdf-&gt;SetFont('Times','B',15);
         $pdf-&gt;SetXY(5,42);
         $pdf-&gt;Cell(190,10,'Challan', 0,0,'C');
         $pdf-&gt;SetXY(5,52);
         $pdf-&gt;SetFont('Times','B',12);
         $pdf-&gt;Cell(150,18,'Name :-', 1,0,'L');
  
  
         $pdf-&gt;Cell(15,0,'$c_n', 0,0,'L');
  
         $pdf-&gt;SetXY(155,52);
         $pdf-&gt;Cell(50,9,'Challan No. :-', 1,2,'L');
         $pdf-&gt;Cell(50,9,'Date :-', 1,0,'L');
         $pdf-&gt;SetXY(5,70);
         $pdf-&gt;Cell(15,15,'Sno', 1,0,'C');
         $pdf-&gt;Cell(35,15,'Type', 1,0,'C');
         $pdf-&gt;Cell(45,15,'Make', 1,0,'C');
         $pdf-&gt;Cell(45,15,'Model', 1,0,'C');
         $pdf-&gt;Cell(45,15,'Serial No.', 1,0,'C');
         $pdf-&gt;Cell(15,15,'Qty', 1,0,'C');
         $pdf-&gt;SetXY(5,85);
         $pdf-&gt;SetFont('Times','',12);
         $pdf-&gt;Cell(15,165,'', 1,0,'L');
         $pdf-&gt;Cell(35,165,'', 1,0,'L');
         $pdf-&gt;Cell(45,165,'', 1,0,'L');
         $pdf-&gt;Cell(45,165,'', 1,0,'L');
         $pdf-&gt;Cell(45,165,, 1,0,'L');
         $pdf-&gt;Cell(170,165,'', 1,0,'L');
         $pdf-&gt;Cell(15,165,'', 1,0,'L');
          $pdf-&gt;SetXY(5,245);
         $pdf-&gt;SetFont('Times','B',12);
         $pdf-&gt;Cell(35,20,'Reciever Name :- ', 0,0,'L');
         $pdf-&gt;SetXY(125,245);
          $pdf-&gt;Cell(35,20,'Reciever Signature :- ', 0,0,'L');
         $pdf-&gt;Output();
            ?&gt;
  </code></pre>
  
  <p>Error : -   File doesnot begin with '%Pdf- '</p>