Help with TCPDF

Hi Experts,

I'm new to TCPDF, but put together the following code:
        //Get Agent List
        $agents = self::get_agent_list($archived, FALSE, 1, FALSE, 'fName');
        
        if ($archived == TRUE){
            $title ='Archived Agents';
        } else {
            $title ='Active Agents';
        }        
        
        //Connect to TCPDF
            //Temporarily Change directory to TCPDF to load files...
            $currentDIR = getcwd();
            chdir("../../tcpdf/examples");
            require_once('tcpdf_include.php');

            //Change DIR back
            chdir($currentDIR);
            
            //Setup PDF File
            $pdf = new TCPDF('P', 'mm', 'Letter');
            $pdf->SetTitle($title);
            $pdf->SetMargins(10, 10, 10);
            $pdf->SetAutoPageBreak(TRUE);
            $pdf->SetFont('helvetica', 'I', 8);
            $pdf->AddPage();

        //Setup Title on p.1
            
        //Data Container
        
            $html = "";
            
            foreach ($agents as $agent){
                $html = $html . $agent['fName'] . "<br>";
            }
            $pdf->writeHTML($html);
            
            //echo $html;        
        //Setup footer
            // Position at 15 mm from bottom
            $pdf->SetY(-15);
            
            $today = new DateTime('today');
            $today_f = $today->format('F d, Y');
            $pdf->Cell(0, 0, $today_f, 0, 0, 'left');
            
            $page = 'Page ' . $pdf->getAliasNumPage() . ' of ' . $pdf->getAliasNbPages();
            $pdf->setX(-30);
            $pdf->Cell(0, 0, $page, 0, 0, 'right');
                                                

        //Page Header, starting p.2
            
        //Generate File
            $file = 'AgentList.pdf';
            $pdf->Output($file);
        

Open in new window


Two things I'm not sure why are they happenning:

1- On the top of every page, I'm getting a horizontal line.

2-My footer only appears on the last page.

Any help would be greatly appreciated.

Thank you.
APD TorontoSoftware DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gr8gonzoConsultantCommented:
Can you attach an example PDF that was generated?
0
APD TorontoSoftware DeveloperAuthor Commented:
Actually I have almost everything figured out, but do you know how to set page size to letter (8.5 x 11)?
0
gr8gonzoConsultantCommented:
Your code already indicates you're using letter:
$pdf = new TCPDF('P', 'mm', 'Letter');

That "Letter" should be defined in the file include/tcpdf_static.php (it's actually case-insensitve, so "Letter", "letter", "LETTER", etc... should all work).

What's it coming out as?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.