dqwh1209 2010-02-07 17:54
浏览 35

FPDF标题问题 - 让我发疯!

I am trying to generate a PDF that outputs Item Names onto a template PDF (using FPDI) with the Username listed on the top of each page. Every user can have a different number of items (i.e. if there are 1-4 items, only output one page; if there 5-8 items, output two pages, etc.)

Here is an example of what I am trying to do: http://www.mediafire.com/?k2ngmqm1jmm

This is what I have so far. I am able to get all of the spacing to work by setting a TopMargin, but this doesn't allow me to put the Username header in.

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

?>

Please help!

  • 写回答

1条回答 默认 最新

  • doutong6814 2010-02-08 06:05
    关注

    I've done it previously using the 'header' class extension:

    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);
    }
    

    Have a look at the tutorial which explains the header usage at : http://www.fpdf.org/en/tutorial/tuto2.htm

    评论

报告相同问题?

悬赏问题

  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染