Displaying values in FPDF

北城余情 提交于 2019-12-05 04:21:45

Why dont you use the standard "header()" extend function of FPDF ? http://fpdf.org/en/doc/header.htm

Add this to your code between line $Y_Table_Position = 46 and line $pdf->Cell(15,50,'Anna University Hostels');, It will display "Semester,Month,Year" color gray in the right top of your page (change Semester,Month,Year with their real values).

    //Fields Name position
    $Y_Fields_Name_position = 40;
    //Table position, under Fields Name
    $Y_Table_Position = 46;
// ABOVE IS YOUR ORIGINAL CODE, ADD The FOLOWING LINES

    $pdf->SetXY(160,0);
    $pdf->SetFont('Times','B',6);
    $pdf->SetTextColor('139','140','142');
    $pdf->Cell(5,15,'Semester,Month,Year',0,0,'L');

    $pdf->SetTextColor('0','0','0');
    $pdf->SetXY(16,8);

// CONTINUE WITH ORIGINAL CODE
    $pdf->Cell(15,50,'Anna University Hostels');
    //First create each Field Name
    //Gray color filling each Field Name box
    $pdf->SetFillColor(232,232,232);

As you see I go to X=160, Y=0 and create a new Cell with the desired text, custom font and color, after that, I change the color to black (beacause my default font color is white) and go to X=16,Y=8 so your "Anna University Hostels" is printed in the same position. After that you're table will be printed as before.

Hope I understad your question, and this is what you're looking for. (if not leave a comment :) )

Set up the stuff you talked about in the header function.

function header()
{
     $this->SetFont('whatever the font u like','B',23)//I just randomly set fonts
     $this->Cell(30,10,'$_POST['user_id']',0,0,'C');
     ...
     ...
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!