您好我正在使用fpdf自动生成pdf以从sql>中读取数据,因为大部分内容从数据库中提取了大约300字的段落..没有被我在fpdf中创建的列包裹...刚刚作为一个单行。是否有任何方法将文本包装在列中。输出图像附在帖子的末尾。还有一个问题,如何将此pdf自动发送到电子邮件
<?php
require('fpdf.php');
//Connect to your database
$link = mysql_connect('www.xxxxxxx.co.uk', 'xxxxxxx', 'xxxxxx');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
//Create new pdf file
$pdf=new FPDF();
//Open file
$pdf->Open();
//Disable automatic page break
$pdf->SetAutoPageBreak(true);
//Add first page
$pdf->AddPage();
//set initial y axis position per page
$y_axis_initial = 25;
//print column titles for the actual page
$pdf->SetFillColor(232, 232, 232);
$pdf->SetFont('Arial', 'B', 12);
$pdf->SetY($y_axis_initial);
$pdf->SetX(5);
/*$pdf->Cell(30, 6, 'CODE', 1, 0, 'L', 1);
$pdf->Cell(30, 6, 'NAME', 1, 0, 'L', 1);
$pdf->Cell(30, 6, 'PRICE', 1, 0, 'R', 1);*/
$y_axis = $y_axis + $row_height;
mysql_select_db("web39-sdasdasd", $link);
$q = "SELECT qr_topics,start_of,differential_dia,things_not,investigations,risks FROM qr_table";
$result = mysql_query ($q, $link);
//initialize counter
$i = 0;
//Set maximum rows per page
$max = 25;
//Set Row Height
$row_height = 80;
$pdf->Cell(33, 6, ' ', 1, 0, 'L', 1);
$pdf->Cell(33, 6, 'Starting off', 1, 0, 'L', 1);
$pdf->Cell(33, 6, 'Differential diagnosis', 1, 0, 'L', 1);
$pdf->Cell(33, 6, 'Not to miss', 1, 0, 'L', 1);
$pdf->Cell(33, 6, 'Investigations', 1, 0, 'L', 1);
$pdf->Cell(33, 6, 'Risks', 1, 0, 'L', 1);
$y_axis =(35);
while($row = mysql_fetch_array($result))
{
$cad = $row['qr_topics'];
$pad = $row['start_of'];
$nad = $row['differential_dia'];
$vad = $row['things_not'];
$sad = $row['investigations'];
$tad = $row['risks'];
$pdf->SetY($y_axis);
$pdf->SetX(5);
$pdf->Cell(33,80,$cad,1,0,'L',1);
$pdf->Cell(33,80,$pad,1,0,'L',1);
$pdf->Cell(33,80,$nad,1,0,'L',1);
$pdf->Cell(33,80,$vad,1,0,'L',1);
$pdf->Cell(33,80,$sad,1,0,'L',1);
$pdf->Cell(33,80,$tad,1,0,'L',1);
//Go to next row
$y_axis = $y_axis + $row_height;
$i = $i + 1;
}
mysql_close($link);
//Send file
$pdf->Output();
?>
输出如下所示
答案 0 :(得分:1)
$row_height = 80;
$pdf->Cell(33, 6, ' ', 1, 0, 'L', 1);
$pdf->Cell(33, 6, 'Starting off', 1, 0, 'L', 1);
$pdf->Cell(33, 6, 'Differential diagnosis', 1, 0, 'L', 1);
$pdf->Cell(33, 6, 'Not to miss', 1, 0, 'L', 1);
$pdf->Cell(33, 6, 'Investigations', 1, 0, 'L', 1);
$pdf->Cell(33, 6, 'Risks', 1, 0, 'L', 1);
从L更改为T或R