2012-06-20 1 views
3

Привет, я использую fpdf, чтобы автоматически генерировать PDF-файл для чтения данных из sql>, поскольку большая часть контента вытащила из db его абзаца около 300 слов. Не обернуты столбцами, которые я сделал в fpdf .. это просто идет как а одиночный line..Is Есть ли способ, чтобы обернуть текст с в колонке .output изображения прилагаются в конце post..One дополнительной questain, как я могу отправить этот PDF-файл по электронной почте автоматическиНужно ли выравнивать верх и обтекать текст при использовании FPDF?

<?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(); 
?> 

выход показан ниже

enter image description here

ответ

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

+0

Согласно документации и моим собственным испытаниям, «T» относится только к добавлению границы вверху. http://www.fpdf.org/en/doc/cell.htm – bytespider

Смежные вопросы