<?php
mysql_connect('localhost','root','');
mysql_select_db('mydatabase');
ob_start();
header('Content-Type: application/pdf');
include_once('pdf/fpdf.php');
$pdf=new FPDF();
get_class_methods($pdf);
$pdf->AddCol('firstname',30,'firstname');
$pdf->AddCol('lastname',30,'lastname');
$pdf->AddCol('address1',30,'Address');
$pdf-> AddCol('address2',30,'Address');
$pdf->AddCol('postCode',30,'Post Code');
$pdf->AddCol('towns',30,'Town');
$pdf->Table("select firstname,lastname from mytable");
$pdf->Output();
ob_end_flush();
这是我将数据库导出为PDF文档的PHP代码。它显示错误,因为无法打开PDF文档文件。
答案 0 :(得分:0)
尝试以下代码: -
<?php
require_once('fpdf17/fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Write(5,"Hello, World!\n\n\n");
$pdf->Output('pdf.pdf', 'F');
?>