4

嗨,我正在使用 fpdf 自动生成 pdf 以从 sql 读取数据>因为从 db 中提取的大部分内容都是大约 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();
?>

输出如下所示

在此处输入图像描述

4

1 回答 1

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

于 2012-07-02T11:50:10.107 回答