首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >标题问题-快把我逼疯了!

标题问题-快把我逼疯了!
EN

Stack Overflow用户
提问于 2010-02-08 01:54:16
回答 1查看 3K关注 0票数 2

我正在尝试生成一个PDF,输出项目名称到一个模板PDF (使用FPDI)与用户名列出在每个页面的顶部。每个用户可以有不同数量的项目(例如,如果有1-4个项目,则只输出一页;如果有5-8个项目,则输出两页,依此类推)

下面是我正在尝试做的一个示例:http://www.mediafire.com/?k2ngmqm1jmm

这就是我到目前为止所拥有的。我可以通过设置一个TopMargin来设置所有的空格,但是这不允许我放入Username头。

代码语言:javascript
运行
复制
<?php
require_once('auth.php');      
require_once('config.php');  
require_once('connect.php');  

$username=$_GET['username'];

$sql="SELECT * FROM $tbl_items WHERE username='$username'";
$result=mysql_query($sql);

require_once('pdf/fpdf.php');
require_once('pdf/fpdi.php');

$pdf =& new FPDI(); 
$pdf->SetTopMargin(30);
$pdf->AddPage('L', 'Letter');
$pdf->setSourceFile('../pdf/files/chart_template.pdf');
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx);

$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial', 'B');
$pdf->SetFontSize(7);

while($rows=mysql_fetch_array($result)){

$pdf->Cell(20,5,$rows['itemname'],0,0,'C');
$pdf->Ln(45);
}

$pdf->useTemplate($tplIdx);

$pdf->Output('file.pdf', 'I');

?>

请帮帮我!

EN

回答 1

Stack Overflow用户

发布于 2010-02-08 14:05:58

我之前已经使用'header‘类扩展做到了这一点:

代码语言:javascript
运行
复制
class PDF extends FPDF
{
function Header()
{
    //Select Arial bold 15
    $this->SetFont('Arial','B',15);
    //Move to the right
    $this->Cell(80);
    //Framed title
    $this->Cell(30,10,'Title',1,0,'C');
    //Line break
    $this->Ln(20);
}

看一下教程,它解释了头部的用法:http://www.fpdf.org/en/tutorial/tuto2.htm

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2217646

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档