require_once ('include/fpdf/fpdf17/fpdf.php');
require_once ('include/connection.php');
// require_once('include/fpdf/fpdf17/mem_image.php');
if (isset($_POST['txtid'])) {
$id = $_POST['txtid'];
$query = "select * from voter where v_id='$id';";
$result = mysql_query($query);
$count = mysql_num_rows($result);
if ($count == 1) {
$data = mysql_fetch_array($result);
$row = mysql_fetch_assoc($result);
$vid = $data['v_id'];
$name = $data['name'];
$surname = $data['surname'];
$father = $data['father_name'];
$birth = $data['DOB'];
$gender = $data['gender'];
$image = $row['photo'];
$address = $data['address'];
$email = $data['email_id'];
$mobile = $data['mobile'];
$ward = $data['ward_no'];
$proof = $data['voter_id_proof'];
$pdf = new fpdf();
$pdf->AddPage();
$pdf->SetFont('Times', '', 15);
$pdf->Cell(20, 10, 'Voter ID: ');
$pdf->Setx(50);
$pdf->Cell(20, 10, $vid, 0, 1);
$pdf->Cell(13, 10, 'Name: ');
$pdf->Setx(50);
$pdf->Cell(20, 10, $name, 0, 1);
$pdf->Cell(10, 10, 'Surname: ');
$pdf->Setx(50);
$pdf->Cell(20, 10, $surname, 0, 1);
$pdf->Cell(20, 10, 'Father Name: ');
$pdf->Setx(50);
$pdf->Cell(20, 10, $father, 0, 1);
$pdf->Cell(20, 10, 'Date of Birth: ');
$pdf->Setx(50);
$pdf->Cell(20, 10, $birth, 0, 1);
$pdf->Cell(20, 10, 'Gender: ');
$pdf->Setx(50);
$pdf->Cell(20, 10, $gender, 0, 1);
$pdf->Cell(20, 5, 'Photo: ');
$pdf->Setx(50);
$pdf->MemImage($image, 50, 30, 40);
$pdf->cell(20, 10, 'address: ');
$pdf->Setx(50);
$pdf->Cell(20, 10, $address, 0, 1);
$pdf->Cell(20, 10, 'Email ID: ');
$pdf->Setx(50);
$pdf->Cell(20, 10, $email, 0, 1);
$pdf->Cell(20, 10, 'Mobile NO.: ');
$pdf->Setx(50);
$pdf->Cell(20, 10, $mobile, 0, 1);
$pdf->Cell(20, 10, 'Ward NO.: ');
$pdf->Setx(50);
$pdf->cell(20, 10, $ward, 0, 1);
$pdf->cell(20, 10, 'ID Proof');
$pdf->Setx(50);
$pdf->cell(20, 10, $proof, 0, 1);
$pdf->Output();
}
else {
echo "<script language='javascript'>";
echo "alert('Please Enter Your Valid Voter Id');";
echo "</script>";
}
}
?>
此代码显示此错误:
Fatal error:
Call to undefined method FPDF::MemImage() in C:\wamp\www\Election Portal\generate_pdf.php on line 50
答案 0 :(得分:0)
从documentation上提供的示例中,您需要mem_image
加载项(您在顶部注释掉的行)。由于附加组件扩展了FPDF
类,因此需要实例化子类,因此请更改
$pdf = new fpdf();
到
$pdf=new MEM_IMAGE();