我希望这个 php 变量显示在 pdf 文件中。但它给出了错误:- Pdf 文件不以 '%Pdf-' 开头
A.php 它包含我的表单。通过使用 post 我将值发送到其他 printpdf.php 其中 printpdf.php 生成具有特定格式的 pdf 文件。
一个.php
 <form class="mid" action="printpdf.php" method="post"> 
 <input type="hidden" id="cname" name="cname" value="<?php echo $c_n[0]; ?>"/>
  <input type="submit" id="but" value="Print Challan"/>     
 </form>
打印pdf.php
 <?php
  $c_n = $_POST['cname'];
  require('fpdf.php');
 class PDF extends FPDF
     {
     function Header()
    {
       $this->Image('image.jpg',5,5,200);
       $this->Ln(20);
       }
     //Page footer
     function Footer()
   {
       $this->SetFont('Arial','I',8);
       $this->Image('image1.jpeg',5,275,200);
       $this->SetXY(5, 284);
       $this->Cell(0,5,'This is a system generated ',0,2,'C');
       $this->Cell(0,5,'Page '.$this->PageNo().'/{nb}',0,0,'C');
       }
        }
         //Instanciation of inherited class
       $pdf=new PDF();
       $pdf->AliasNbPages();
       $pdf->AddPage();
       $pdf->SetFont('Times','B',15);
       $pdf->SetXY(5,42);
       $pdf->Cell(190,10,'Challan', 0,0,'C');
       $pdf->SetXY(5,52);
       $pdf->SetFont('Times','B',12);
       $pdf->Cell(150,18,'Name :-', 1,0,'L');
       $pdf->Cell(15,0,'$c_n', 0,0,'L');
       $pdf->SetXY(155,52);
       $pdf->Cell(50,9,'Challan No. :-', 1,2,'L');
       $pdf->Cell(50,9,'Date :-', 1,0,'L');
       $pdf->SetXY(5,70);
       $pdf->Cell(15,15,'Sno', 1,0,'C');
       $pdf->Cell(35,15,'Type', 1,0,'C');
       $pdf->Cell(45,15,'Make', 1,0,'C');
       $pdf->Cell(45,15,'Model', 1,0,'C');
       $pdf->Cell(45,15,'Serial No.', 1,0,'C');
       $pdf->Cell(15,15,'Qty', 1,0,'C');
       $pdf->SetXY(5,85);
       $pdf->SetFont('Times','',12);
       $pdf->Cell(15,165,'', 1,0,'L');
       $pdf->Cell(35,165,'', 1,0,'L');
       $pdf->Cell(45,165,'', 1,0,'L');
       $pdf->Cell(45,165,'', 1,0,'L');
       $pdf->Cell(45,165,, 1,0,'L');
       $pdf->Cell(170,165,'', 1,0,'L');
       $pdf->Cell(15,165,'', 1,0,'L');
        $pdf->SetXY(5,245);
       $pdf->SetFont('Times','B',12);
       $pdf->Cell(35,20,'Reciever Name :- ', 0,0,'L');
       $pdf->SetXY(125,245);
        $pdf->Cell(35,20,'Reciever Signature :- ', 0,0,'L');
       $pdf->Output();
          ?>
错误:- 文件不以“%Pdf-”开头