我想要這個php變量顯示在pdf文件中。但它給出了錯誤: - PDF文件不以'%Pdf-'開始顯示使用fpdf生成的pdf文件中的php變量
A.php它包含我的表單。通過使用後,我發送值給其他printpdf.php 其中printpdf.php生成一個具有特定格式的PDF文件。
a.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>
printpdf.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-
什麼是*精確*和*完整*錯誤信息? – str
你打電話給你的PDF課程? – andrewsi
@str每當我寫這行$ c_n = $ _POST ['cname'];和$ pdf-> Cell(15,0,'$ c_n',0,0,'L');我得到錯誤: - 文件不以'%Pdf-'開頭 – Abhishek