Jump to content

help with wrapping description in pdf invoice


decor

Recommended Posts

hello

I brought a template for html & pdf invoivces from someone here but can nott seem to find the reciept. So can someone help me with wrapping the invoice description?

 

currently i have (the description part only of pdfconfig.php

-----------------------------------------

 

$pdf->Cell(50,9,"Total Amount Due",1,0,'L',1);

$pdf->Cell(30,9,$duedate,1,0,'L',1);

$pdf->Cell(30,9,$currencysymbol.$grandtotal,1,0,'R',1);$pdf->Ln();

 

$pdf->SetTextColor(0);

 

$pdf->Cell(80,9,"Balance Brought Forward",0,0,'L',0);

$pdf->Cell(30,9,$currencysymbol.$balancebroughtforward,0,0,'R',0);$pdf->Ln();$pdf->Ln();

 

foreach ($invoiceitems AS $item) {

$pdf->Cell(80,0,$item["description"],0,0,'L',0);

$pdf->Cell(30,0,$currencysymbol.$item["amount"],0,0,'R',0);$pdf->Ln();

}

 

# TOTALS

--------------------------------------------------

 

which will write one long line across the page when the description is long.

 

How do i wrap the description at say 70 characters?

 

thanks

ian

Link to comment
Share on other sites

  • 2 weeks later...

Take a look at the latest 3.8.1 pdfconfig.php file.

 

They have implemented new code in the area you are looking at to wrap a bit better.

 

G

 

foreach ($invoiceitems AS $item) {
   if (strlen($item["description"])>75) {
       $numlines = ceil(strlen($item["description"])/75);
       $cellheight = $numlines * 5;
       $pdf->MultiCell(130,$cellheight,$item["description"],1,'L','',0);
       $pdf->MultiCell(40,$cellheight,$currencysymbol.$item["amount"],1,'C','',0);
       $pdf->SetXY(20,$pdf->GetY());
   } else {
               $pdf->Cell(130,6,$item["description"],1);
               $pdf->Cell(40,6,$currencysymbol.$item["amount"],1,0,'C');
       }
       $pdf->Ln();
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated