2017-02-15 73 views
2

我开始使用FPDF从Mysql导出pdf。现在我可以导出PDF。我引用了this linkthis link,但我仍然无法更改单元格宽度和文本宽度。 任何人都可以提供任何建议吗?非常感谢你。使用FPDF自动调整文本宽度使用文本宽度

<?php 
require('mysql_table.php'); 

class PDF extends PDF_MySQL_Table 
{ 
function Header() 
{ 
//Title 
$this->SetFont('Arial','',18); 
$this->Cell(0,6,'Test',0,1,'C'); 
$this->Ln(10); 
//Ensure table header is output 
parent::Header(); 
} 
} 

mysql_connect('localhost','root',''); 
mysql_select_db('test'); 
$query = "SELECT * FROM test"; 
$result = mysql_query($query) or die(mysql_error()); 
$rowCount = 2; 
while($row = mysql_fetch_array($result)){ 
$thisid = $row['ID']; 
$fileName =$row['name']; 
$filepath = $row['path']; 
$date = $row['date']; 
$rowCount++; 
} 
$pdf=new PDF('P','mm',array(1000,1500)); 
$pdf->AddPage(); 
$pdf->Table('select * from test'); 
$pdf->AddPage(); 
$pdf->SetFont('Arial','',14); 
$pdf->Cell('','',$thisid,1); 
$pdf->Cell('','',$fileName,1); 
$pdf->Cell('','','','','','',false,$filepath); 
$pdf->Cell('','',$date); 
$pdf->Output(); 
?> 

回答

0

检查下面的答案来设置单元格的宽度 Inserting an image with PHP and FPDF, failed to load big image

根据你的问题,你可能需要通过宽度和高度像下面cell()功能

$pdf->cell(1000,1000,'',$pdf->Image($image,10,10,235,$height*18/100),'PNG'); 

这是为了调整单元格和加载img到相同的

相关问题