Solved

FPDF Formatting

Posted on 2010-11-22
3
1,359 Views
Last Modified: 2012-05-10
Hi I have a letter produced by my system that needs a VERY basic table with no data pulling from the MySQL database.  I can't seem to get the text to wrap inside the box.  I tried everything I can think of.  At the moment the code is not in a "table" structure, I did try that earlier, but I was unable to wrap the text.   Any help is appreciated.  Thank you. Current Mess What I would like or a close approximation
<?php
require('../../fpdf/html_table.php');
include "../../../login-system/include/loginGlobals.php";
include "../../../login-system/include/database.php";
include "../../../include/userConnect.php";

//Page footer
function Footer()
{
    //Position at 1.5 cm from bottom
    $this->SetY(-15);
    //Arial italic 8
    $this->SetFont('Arial','I',12);
    //Page number
    $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}

$pdf = new PDF();
$pdf->open();
$pdf->AddPage();
$pdf->AliasNbPages();   // necessary for x of y page numbers to appear in document
$pdf->SetAutoPageBreak(true);

//Move to the right
    $pdf->Cell(50);
    //Logo
    //$pdf->Image('../../../images/ermQCLogo.png',15,8,75);
    //Line break
    $pdf->Ln(5);
    //Arial bold 12
    $pdf->SetFont('Arial','B','U',12);
    //Move to the right
    $pdf->Cell(75);
    //Title
    $pdf->Cell(30,10,'CONFIDENTIAL',0,0,'C');

// Add date report ran
//$pdf->SetFont('Arial','I',10);
//$date =  date("F j, Y");
//$pdf->Cell(40,30,'Report date: '.$date);

$pdf->SetDrawColor(0, 0, 0); //black

//table header
$pdf->SetFillColor(170, 170, 170); //gray
$pdf->setFont("Arial","B","12");
$pdf->setXY(5, 20);


$y = 35;
$x = 10;

$pdf->setXY($x, $y);

$pdf->setFont("Arial","","12");


 error_reporting(E_ALL);
       
   
      if (array_key_exists('reprocessingKey', $_POST)) {
          $reprocessingKey = $_POST['reprocessingKey'];
          } else {
          $reprocessingKey = $_GET['reprocessingKey'];
          }
           //letter information for DEPOSIT/GIFTS

    $deposit= "SELECT * FROM reprocessing JOIN audit USING (auditID) JOIN loan USING (loanKey)  JOIN parent USING (parentKey) JOIN branch on branch.branchKey=loan.branchKey JOIN client USING (clientKey) JOIN state ON state.stateKey=reprocessing.repStateKey JOIN reprocessingType USING (reprocessingTypeKey) WHERE reprocessing.active='1' AND reprocessingKey='$reprocessingKey' and reprocessingTypeKey='3' ";
    $depositList = mysql_query($deposit) or die(mysql_error());
    $depositRow = mysql_fetch_assoc($depositList);
    $loanKey = $depositRow['loanKey'];
    $trackingDate = $depositRow['trackingDate'];
    $loanNumber = $depositRow['loanNumber'];
    $clientName=$depositRow['clientName'];
    $companyName=$depositRow['companyName'];
    $repStAddress = $depositRow['repStAddress'];
    $repStAddress2 = $depositRow['repStAddress2'];
    $repAttn=$depositRow['repAttn'];
    $repCity = $depositRow['repCity'];
    $stateAbbr=$depositRow['stateAbbr'];
    $repZip=$depositRow['repZip'];
    $accountNumber=$depositRow['accountNumber'];
    $borrower= "SELECT * FROM loan JOIN audit USING (loanKey)JOIN borrower USING (loanKey) JOIN reprocessing USING (auditID) JOIN reprocessingBorr ON borrower.borrowerKey=reprocessingBorr.borrowerKey WHERE reprocessingTypeKey='3' AND reprocessing.reprocessingKey='$reprocessingKey' AND reprocessingBorr.active='1'";
    $borrowerList = mysql_query($borrower) or die(mysql_error());
    

    $pdf->setXY(200, 5);
    //Line break
    $pdf->Ln(0);
    $pdf->SetFont('Arial','',8);
    //Move to the right
    $pdf->Cell(150);
    //Client Name
    $pdf->Cell(0, 10, $depositRow['clientName'],0,0,'R');
    //Line break
    $pdf->Ln(3);
   //Tracking date (Jun 10)
    $pdf->Cell(0, 10,$depositRow['trackingDate'],0,0,'R');
    $pdf->Ln(0);
    $pdf->setFont("Arial","","12");
    $pdf->setXY($pdf->GetX(), 30);
// Check to determine attn field includes or excludes as needed
   if (array_key_exists('repAttn', $_POST)) {

$pdf->Cell( 40, 4,$depositRow['companyName'],0,'L');
//Line break
$pdf->Ln(4);
$pdf->Cell( 40, 4,$depositRow['repAttn'],0,'L');
$pdf->Ln(4);
$pdf->Cell( 40,4,$depositRow['repStAddress'],0,'L');
$pdf->Cell(1);
$pdf-Cell( 20,4,$depositRow['repStAddress2'],0,'L');
$pdf->Ln(4);
$pdf->Write( 4,$depositRow['repCity']);
$pdf->Write(4,',  ');
$pdf->Cell( 2, 4,$depositRow['stateAbbr'],0,'L');
$pdf->Write(4,' ');
$pdf->Cell( 10, 4,$depositRow['repZip'],0,'L');

//$pdf->Cell(40,30,'Report date: '.$date);
    
      } else {
          $pdf->Cell( 40, 4,$depositRow['companyName'],0,'L');
          $pdf->SetXY($pdf->GetX()+90,$pdf->GetY());
          $pdf->Write(4,'Loan #:  '.$depositRow['loanNumber'],0,'R');
//Line break
$pdf->Ln(4);
$pdf->Write(4,$depositRow['repStAddress'],0,'L');
$pdf->Cell(1);
$pdf->Write( 4,$depositRow['repStAddress2'],0,'L');
$pdf->SetXY($pdf->GetX()+91,$pdf->GetY());
$pdf->Write(4,'Date:  '.$depositRow['loanNumber'],0,'L');
$pdf->Ln(4);
$pdf->Write( 4,$depositRow['repCity']);
$pdf->Write(4,', ');
$pdf->Cell( 4, 4,$depositRow['stateAbbr'],0,'L');
$pdf->Cell(2);
$pdf->Cell( 10, 4,$depositRow['repZip'],0,'L');
$pdf->SetXY($pdf->GetX()+90,$pdf->GetY());
$pdf->Write(4,'Account #:  '.$depositRow['loanNumber'],0,'L');
$pdf->Ln(4);
$pdf->SetXY($pdf->GetX()+130,$pdf->GetY());
$pdf->Cell( 10, 4,'Borrower(s):  ',0,'L');
$pdf->SetXY($pdf->GetX()+13,$pdf->GetY());
while($borrowerRow = mysql_fetch_array($borrowerList))
{
$pdf->Write(4,$borrowerRow['firstName'],0,'L');
$pdf->Cell(30,4,' '.$borrowerRow['lastName'],0,'L');
$pdf->Ln(4);
$pdf->SetXY($pdf->GetX()+130,$pdf->GetY());



          }}

          $pdf->Ln(10);
          $pdf->Write(4,$depositRow['parentName']);
          $pdf->Write(4,' conducts audits for ');
          $pdf->Write( 4,$depositRow['clientName']);
          $pdf->Write(4,'.  Enclosed is a copy of the documentation that was used for qualifying purposes.  Please verify the attachments and complete ');
          $pdf->Ln(4);
          $pdf->Write( 4, 'the items listed below.  We have enclosed a self addressed stamped envelope for your convenience.  ');
          $pdf->SetFont('','B');
          $pdf->Write( 4,'You can also fax the form to ',0,'L');
          $pdf->Write(4,$depositRow['parentFax']);
          $pdf->Ln(8);
          $pdf->SetFont('','BU');
          $pdf->Cell( 30, 4,'Please return cover letter only, attachments are for your records',0,'L');
          $pdf->Ln(8);
          $pdf->setFont("Arial","","12");
          $pdf->Cell( 30, 4,$depositRow['parentDept'],0,'L');
          $pdf->Ln(8);
          $pdf->Cell( 30, 4,'1.  Is the attached documentation correct as of the date it was issued?',0,'L');
          $pdf->Ln(6);
          $pdf->SetLineWidth(0.2);
          $pdf->Cell(10,4,'','');
          $pdf->Rect($pdf->GetX(),$pdf->GetY(),3,3,'D');
          $pdf->Cell( 30, 4,'   Yes, the enclosed documentation is accurate',0,'L');
          $pdf->Ln(4);
          $pdf->SetLineWidth(0.2);
          $pdf->Cell(10,4,'','');
          $pdf->Rect($pdf->GetX(),$pdf->GetY(),3,3,'D');
          $pdf->Cell( 30, 4,'   No, the enclosed documentation is not accurate for the folllowing reasons:',0,'L');
          $pdf->Ln(10);
          $pdf->Line($pdf->GetX()+10,$pdf->GetY(),$pdf->GetX()+185,$pdf->GetY());
          $pdf->Ln(6);
          $pdf->Line($pdf->GetX()+10,$pdf->GetY(),$pdf->GetX()+185,$pdf->GetY());
          $pdf->Ln(4);
          $pdf->Cell( 30, 4,'2.  Do you have any additional information or comments regarding the documentation?',0,'L');
          $pdf->Ln(6);
          $pdf->SetLineWidth(0.2);
          $pdf->Cell(10,4,'','');
          $pdf->Rect($pdf->GetX(),$pdf->GetY(),3,3,'D');
          $pdf->Cell( 30, 4,'   Yes',0,'L');
          $pdf->Ln(10);
          $pdf->Line($pdf->GetX()+10,$pdf->GetY(),$pdf->GetX()+185,$pdf->GetY());
          $pdf->Ln(6);
          $pdf->Line($pdf->GetX()+10,$pdf->GetY(),$pdf->GetX()+185,$pdf->GetY());
          $pdf->SetLineWidth(0.2);
          $pdf->Ln(2);
          $pdf->Cell(10,4,'','');
          $pdf->Rect($pdf->GetX(),$pdf->GetY(),3,3,'D');
          $pdf->Cell( 30, 4,'   No',0,'L');
          $pdf->Ln(8);
          $pdf->SetFont('Arial','B',12);
          //Move to the right
          $pdf->Cell(78);
          //VOD Grid
          $pdf->Cell(30,10,'VERIFICATION OF DEPOSIT',0,0,'C');
          $pdf->SetFont('Arial','B',12);
          $pdf->Ln(10);
          $pdf->SetLineWidth(0.3);


          $pdf->Cell(30,10,$pdf->MultiCell(30,6,'Date Account Opened',0,'C'),1,0,'C');
          $pdf->Cell(30,10,$pdf->MultiCell(30,6,'Account in the Name of',0,'C'),1,0,'C');
          $pdf->MultiCell(75,6,'Provide account balance as of the date of attached document',0,'C');
          $pdf->MultiCell(30,6,'Date Closed, if applicable',0,'C');

          
         


          $pdf->Ln(8);
          $pdf->Cell( 40, 4,'Print Your Name: ',0,'R');
          $pdf->Line($pdf->GetX(),$pdf->GetY()+4,$pdf->GetX()+50,$pdf->GetY()+4);
          $pdf->Ln(8);
          $pdf->Cell( 40, 4,'Your Signature: ',0,'R');
          $pdf->Line($pdf->GetX(),$pdf->GetY()+4,$pdf->GetX()+50,$pdf->GetY()+4);
          $pdf->setXY($pdf->GetX()+57, $pdf->GetY());
          $pdf->Cell( 40, 4,'Date: ',0,'R');
          $pdf->Line($pdf->GetX(),$pdf->GetY()+4,$pdf->GetX()+50,$pdf->GetY()+4);
          $pdf->Ln(8);
          $pdf->Cell( 40, 4,'Your Title: ',0,'R');
          $pdf->Line($pdf->GetX(),$pdf->GetY()+4,$pdf->GetX()+50,$pdf->GetY()+4);
          $pdf->setXY($pdf->GetX()+57, $pdf->GetY());
          $pdf->Cell( 40, 4,'Phone Number: ',0,'R');
          $pdf->Line($pdf->GetX(),$pdf->GetY()+4,$pdf->GetX()+50,$pdf->GetY()+4);
          $pdf->Ln(10);
          $pdf->SetFont('Arial','B',8);
          $pdf->Ln(8);
          //Move to the right
          $pdf->Cell(78);
          $pdf->Cell( 30, 4,"****IMPORTANT****",0,'C');
          $pdf->Ln(4);
          $pdf->Cell(30, 4, 'To Whom It May Concern:');
          $pdf->Ln(4);
          $pdf->Write( 4, 'Due to Privacy concerns, ');
          $pdf->Write(4, $depositRow['parentName']);
          $pdf->Write( 4," puts forth every effort to protect the identity of the borrower.  Therefore, individual's social security numbers have been blocked from necessary attachments.  If you need the individual's social security number to verify attached ");
          $pdf->Ln(4);
          $pdf->Write(4,"information please feel free to call us at ");
          $pdf->Write(4, $depositRow['parentPhone']);
          $pdf->Write(4, ' and ask to speak with our ');
          $pdf->Write(4, $depositRow['parentDept']);
          $pdf->Write(4, '. Thank you for your understanding in this matter.');
          $pdf->Ln(8);
          //Move to the right
          $pdf->Cell(70);
          $pdf->Write(4,$depositRow['parentAddr'],0,'C');
          $pdf->Cell(1);
          $pdf->Write(4,$depositRow['parentAddr2'],0,'L');
          $pdf->Ln(3);
          $pdf->Cell(75);
          $pdf->Write(4,$depositRow['parentCity'],0,'C');
          $pdf->Write(4,',  ');
          $pdf->Cell( 2, 4,$depositRow['parentStateKey'],0,'L');
          $pdf->Write(4,' ');
          $pdf->Cell( 10, 4,$depositRow['parentZip'],0,'L');
          $pdf->Ln(3);
          $pdf->Cell(83);
          $pdf->Cell( 10, 4,$depositRow['parentPhone'],0,'C');

$pdf->Output();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN http: //www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 </head>
  <body>
   <form enctype="multipart/form-data" method="POST" action="<?php echo $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']; ?>">
   </form>
  </body>

Open in new window

0
Comment
Question by:rcowen00
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
shanikawm earned 500 total points
ID: 34193567
Following example might help,

Table with MultiCells

http://www.fpdf.org/en/script/script3.php

0
 

Author Comment

by:rcowen00
ID: 34194188
Thanks!  I've attached the code that replaced lines 215-218 if anyone is interested.
//VOD Grid
          $pdf->Cell(30,10,'VERIFICATION OF DEPOSIT',0,0,'C');
          $pdf->SetFont('Arial','B',12);
          $pdf->Ln(10);
          $pdf->SetLineWidth(0.3);
          $x=$pdf->GetX();
          $y=$pdf->GetY();
          $pdf->MultiCell(40,6,'Date Account Opened',1,'C');
          $pdf->SetXY($x+40,$y);
          $x1=$pdf->GetX();
          $y1=$pdf->GetY();
          $pdf->MultiCell(40,6,'Account in the Name of',1,'C');
          $pdf->SetXY($x1+40,$y1);
          $x2=$pdf->GetX();
          $y2=$pdf->GetY();
          $pdf->MultiCell(70,6,'Provide account balance as of the date of attached document',1,'C');
          $pdf->SetXY($x2+70,$y2);
          $x3=$pdf->GetX();
          $y3=$pdf->GetY();
          $pdf->MultiCell(40,6,'Date closed if applicable',1,'C');
          $pdf->SetXY($x3+40,$y3);
          $pdf->Ln(12);
          $x4=$pdf->GetX();
          $y4=$pdf->GetY();
          $pdf->MultiCell(40,6,'    /  /    ',1,'C');
          $pdf->SetXY($x4+40,$y4);
          $x5=$pdf->GetX();
          $y5=$pdf->GetY();
          $pdf->MultiCell(40,6,'',1,'C');
          $pdf->SetXY($x5+40,$y5);
          $x6=$pdf->GetX();
          $y6=$pdf->GetY();
          $pdf->MultiCell(70,6,'',1,'C');
          $pdf->SetXY($x6+70,$y6);
          $x7=$pdf->GetX();
          $y7=$pdf->GetY();
          $pdf->MultiCell(40,6,'    /  /    ',1,'C');
          $pdf->SetXY($x7+40,$y7);
          $pdf->Ln(6);
          $x8=$pdf->GetX();
          $y8=$pdf->GetY();
          $pdf->MultiCell(40,6,'    /  /    ',1,'C');
          $pdf->SetXY($x8+40,$y8);
          $x9=$pdf->GetX();
          $y9=$pdf->GetY();
          $pdf->MultiCell(40,6,'',1,'C');
          $pdf->SetXY($x9+40,$y9);
          $x10=$pdf->GetX();
          $y10=$pdf->GetY();
          $pdf->MultiCell(70,6,'',1,'C');
          $pdf->SetXY($x10+70,$y10);
          $x11=$pdf->GetX();
          $y11=$pdf->GetY();
          $pdf->MultiCell(40,6,'    /  /    ',1,'C');
          $pdf->SetXY($x11+40,$y11);
          $pdf->Ln(6);
          $x12=$pdf->GetX();
          $y12=$pdf->GetY();
          $pdf->MultiCell(40,6,'    /  /    ',1,'C');
          $pdf->SetXY($x12+40,$y12);
          $x13=$pdf->GetX();
          $y13=$pdf->GetY();
          $pdf->MultiCell(40,6,'',1,'C');
          $pdf->SetXY($x13+40,$y13);
          $x14=$pdf->GetX();
          $y14=$pdf->GetY();
          $pdf->MultiCell(70,6,'',1,'C');
          $pdf->SetXY($x14+70,$y14);
          $x15=$pdf->GetX();
          $y15=$pdf->GetY();
          $pdf->MultiCell(40,6,'    /  /    ',1,'C');
          $pdf->SetXY($x15+40,$y15);
          $pdf->Ln(10);

Open in new window

0
 
LVL 8

Expert Comment

by:shanikawm
ID: 34194383
Thanks for sharing your effort.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now