Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-10-2004, 10:07 AM   PM User | #1
firestar_lene
New to the CF scene

 
Join Date: May 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
firestar_lene is an unknown quantity at this point
printing mailing label without blank line

i have a problem.i want to print mailing label using pdf.


PHP Code:

$pdf
->Add_PDF_Label(sprintf("%s\n%s\n%s\n%s\n%s %s\n%s %s""".ucwords($realname)."""".ucwords($address1)."""".ucwords($address2)."""".ucwords($address3)."""$postcode""".ucwords($city)."""".ucwords($state)."""".strtoupper($country)."")); 
if one the data is empty,i dont want to leave a blank like,like as below:


name
address1

address3


assume there is no data for address2,it will leave a blank space there.i dont want this to happen.i want to put something like this as below:

PHP Code:

        $pdf
->Add_PDF_Label(sprintf("%s if(!empty($address1))\n%s if(!empty($address2)){\n%s}if(!empty($address3)){\n%s}if(!empty($postcode) or !empty($city)){\n%s %s}if(!empty($state) or !empty($country)){\n%s %s}""".ucwords($realname)."""".ucwords($address1)."""".ucwords($address2)."""".ucwords($address3)."""$postcode""".ucwords($city)."""".ucwords($state)."""".strtoupper($country)."")); 

but it display error when i put the condition(if statement) inside the sprintf..how to put the condition inside?

firestar_lene is offline   Reply With Quote
Old 05-11-2004, 12:09 AM   PM User | #2
sad69
Senior Coder

 
Join Date: Feb 2004
Posts: 1,206
Thanks: 0
Thanked 0 Times in 0 Posts
sad69 is an unknown quantity at this point
I don't know much about sprintf.. but looking briefly at php.net, it looks like it just returns a string. So I'm wondering if you even need to use sprintf and if you can just create a string and pass it to Add_PDF_Label:
PHP Code:
$pdf_label "";
if(!empty(
$realname))
 
$pdf_label .= "".ucwords($realname)."\n";
if(!empty(
$address1))
 
$pdf_label .= "".ucwords($address1)."\n";
if(!empty(
$address2))
 
$pdf_label .= "".ucwords($address2)."\n";
if(!empty(
$address3))
 
$pdf_label .= "".ucwords($address3)."\n";
if(!empty(
$postcode) || !empty($city))
 
$pdf_label .= "$postcode ".ucwords($city)."\n"
if(!empty($state) || !empty($country))
 
$pdf_label .= "".ucwords($state)." ".strtoupper($country)."";  
  
$pdf->Add_PDF_Label($pdf_label); 
That should do it... let me know how that works out for you.

Sadiq.
sad69 is offline   Reply With Quote
Old 05-13-2008, 12:29 PM   PM User | #3
TheWhiteSeal
New to the CF scene

 
Join Date: May 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
TheWhiteSeal is an unknown quantity at this point
On the subject of printing mailing labels labels I would have to admit that I never really had much luck with my label printer. I spent all my time messing around with the printer and it still never printed any decent looking labels. In the end I decided to give up on the whole DIY approach and I found a british labels company to print my mailing labels, they saved me so much hassle.
TheWhiteSeal is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:55 PM.


Advertisement
Log in to turn off these ads.