PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 1st, 2013, 06:28 AM
helenp helenp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383 helenp Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 6 Days 8 h 41 m 34 sec
Reputation Power: 0
Send fpdf with phpmailer as an attachment

Hi,
first I did a simply fpdf script on the fly with values from the database and I sent it using phpmailer without any problems.
Then I worked the fpdf script and added header, footer and phpscripts and queries to get an elaborated fpdf file.
The file is printed perfectly in the browser, but I cant manage to send it anymore.....

This is the fpdf file:
PHP Code:
class PDF extends FPDF
{    
function 
Header()
{
    
$this->Image('paypal/headeringles2.png',10,5,190);
    
$this->SetFont('Arial','B',17);
     
// Salto de línea
    
$this->Ln(6);
    global 
$propiedad;
    
$this->Cell(190,10,$propiedad,0,0,'C'); 
    
$this->Ln(16);  
}
function 
Footer()
{
    
$this->SetFont('Arial','',10);
    
// Número de página
    
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}
  
define('EUR'iconv('UTF-8''windows-1252'"€"));
define('DEG'iconv('UTF-8''windows-1252'"º"));
define('SEP'iconv('UTF-8''windows-1252'"'"));
// Creación del objeto de la clase heredada
$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Arial','',11); 
$pdf->SetX(20);
$pdf->Cell(170,5,'Name: ' $row->name,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5,'Passport: ' $row->passport,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5,'Email: ' $row->emailtrue,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5,'Home phonenumber: ' $row->telhome,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5,'Movile to bring on holiday: ' $row->telmobile,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5,'Adults: ' $row->adults,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5,'Children (2-17 years): ' $row->children,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5,'Infants (under 2 years): ' $row->babies,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$row->propiedad str_replace(" ""_"$row->propiedad);
$casa $row->propiedad;
$result mysql_query ("SELECT Duermen_max, bond FROM Casas_alquilar where (nombre = '$casa')");
while (
$rows mysql_fetch_object($result)) {
$pdf->Cell(170,5,utf8_decode("Máx. occupacy is ") . $rows->Duermen_max ' persons excluding babies or infants who sleep in a cot for which there is',0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'no extra charge.',0,0);
$pdf->Ln(12);
$pdf->SetX(20);
$pdf->Cell(170,5'Property rented: ' .$row->propiedad,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'Arrival: ' $row->llegada,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'Departure: ' .$row->salida,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
if (
$row->percentage=="25"){$whenpayment $whenpayment "is due 8 weeks before arrival";}
if (
$row->percentage=="50"){$whenpayment "is due on arrival";}
$pdf->Cell(170,5'Total Holiday Cost: '$row->holidaycost.EUR,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'Option choosen to pay:',0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'deposit ('.$row->percentage .' %) ' .$row->deposit.EUR.' balance ' .$row->balance.EUR.  ' '$whenpayment.'.',0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'balance ' .$row->balance.EUR.  ' '$whenpayment.'.',0,0);
$pdf->Ln(6);
if (
$row->bond=="tarjeta"){
$pdf->SetX(20);
$pdf->Cell(170,5'A damage deposit will be paid on arrival by creditcard.',0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'I have read the booking conditions and agree to abide by them.',0,0);
$pdf->Ln(12);
}
else {
$pdf->SetX(20);            
$pdf->Cell(170,5'A damage deposit of ' $row->damagedeposit.EUR' wich will be returned after inspection will be blocked on my credit',0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'card or paid on arrival in cash in the currency of my choice.',0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'I have read the booking conditions and agree to abide by them.',0,0);            
$pdf->Ln(12);
}
$pdf->SetX(20);
$pdf->Cell(170,5'Flight or other transport information, arriving: ' $row->transport,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'Arrival and departure time at airport, trainstation or property: ',0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'Arrival time: ' .$row->hourarrival,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'Departure time: ' .$row->hourdeparture,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'Arrival flight: ' .$row->arrivalflightdetails,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'Departure flight: ' .$row->departureflightdetails,0,0);
$pdf->Ln(12);
$pdf->SetX(20);
$pdf->Cell(170,5'Services required: (Air Port pickup to be paid on arrival) ',0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5,'Taxi' .SEP.'s up to 4 persons: ' .$row->taxismall,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5,'Taxi'.SEP.'s up to 7 persons: ' .$row->taxibig,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'n'.DEG.' and group of Rent a car'.SEP.'s: ' .$row->rentacar,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'n'.DEG.' of cots (free of charge): ' .$row->cot,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'Other services: ' .$row->otherservices,0,0);
$pdf->Ln(9);
$pdf->SetFont('Arial','',8);
$pdf->SetX(20);
$pdf->Cell(170,5'All charges of bank transfers to be paid by the guest. If the option of credit or debit card payment is chosen there will be a 4%  charge to the guest.',0,0);
$pdf->Ln(4);
$pdf->Image('paypal/footeringles2.png',40,278,140);

}
$pdf->Output(); 


And this is the way I did sent it before using phpmailer:
$doc=$pdf->Output('Booking /' .$row->hourdeparture.'/','S');
$mail->AddStringAttachment($doc, 'Booking /' .$row->hourdeparture.'/', 'base64', 'application/pdf');
$mail->Send();

Any help please

Reply With Quote
  #2  
Old January 1st, 2013, 12:20 PM
helenp helenp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383 helenp Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 6 Days 8 h 41 m 34 sec
Reputation Power: 0
Changing $pdf new PDF (); to
$pdf=new FPDF('P','mm','A4');
trying to debug I managed to send (not sure all but at least what I tried)
However the image in the header did not appear on the pdf I received.
Maybe the file should be saved and then sent?
Any ideas as I ever sent attachments or saved files?

Reply With Quote
  #3  
Old January 2nd, 2013, 06:27 AM
helenp helenp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383 helenp Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 6 Days 8 h 41 m 34 sec
Reputation Power: 0
This now works if anybody is interested:
PHP Code:
class PDF extends FPDF
{    
function 
Header()
{
    
$this->Image('headeringles2.png',10,5,190);
    
$this->SetFont('Arial','B',17);
     
// Salto de línea
    
$this->Ln(6);
    global 
$propiedad;
    
$this->Cell(190,10,$propiedad,0,0,'C'); 
    
$this->Ln(16);  
}
function 
Footer()
{
    
$this->SetFont('Arial','',10);
    
// Número de página
    
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}
  
define('EUR'iconv('UTF-8''windows-1252'"€"));
define('DEG'iconv('UTF-8''windows-1252'"º"));
define('SEP'iconv('UTF-8''windows-1252'"'"));
// Creación del objeto de la clase heredada
$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Arial','',11); 
$pdf->SetX(20);
$pdf->Cell(170,5,'Name: ' $row->name,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5,'Passport: ' $row->passport,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5,'Email: ' $row->emailtrue,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5,'Home phonenumber: ' $row->telhome,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5,'Movile to bring on holiday: ' $row->telmobile,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5,'Adults: ' $row->adults,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5,'Children (2-17 years): ' $row->children,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5,'Infants (under 2 years): ' $row->babies,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$row->propiedad str_replace(" ""_"$row->propiedad);
$casa $row->propiedad;
$result mysql_query ("SELECT Duermen_max, bond FROM Casas_alquilar where (nombre = '$casa')");
while (
$rows mysql_fetch_object($result)) {
$pdf->Cell(170,5,utf8_decode("Máx. occupacy is ") . $rows->Duermen_max ' persons excluding babies or infants who sleep in a cot for which there is',0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'no extra charge.',0,0);
$pdf->Ln(12);
$pdf->SetX(20);
$pdf->Cell(170,5'Property rented: ' .$row->propiedad,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'Arrival: ' $row->llegada,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'Departure: ' .$row->salida,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
if (
$row->percentage=="25"){$whenpayment $whenpayment "is due 8 weeks before arrival";}
if (
$row->percentage=="50"){$whenpayment "is due on arrival";}
$pdf->Cell(170,5'Total Holiday Cost: '$row->holidaycost.EUR,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'Option choosen to pay:',0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'deposit ('.$row->percentage .' %) ' .$row->deposit.EUR,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'balance ' .$row->balance.EUR.  ' '$whenpayment.'.',0,0);
$pdf->Ln(6);
if (
$row->bond=="tarjeta"){
$pdf->SetX(20);
$pdf->Cell(170,5'A damage deposit will be paid on arrival by creditcard.',0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'I have read the booking conditions and agree to abide by them.',0,0);
$pdf->Ln(12);
}
else {
$pdf->SetX(20);            
$pdf->Cell(170,5'A damage deposit of ' $row->damagedeposit.EUR' wich will be returned after inspection will be blocked on my credit',0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'card or paid on arrival in cash in the currency of my choice.',0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'I have read the booking conditions and agree to abide by them.',0,0);            
$pdf->Ln(12);
}
$pdf->SetX(20);
$pdf->Cell(170,5'Flight or other transport information, arriving: ' $row->transport,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'Arrival and departure time at airport, trainstation or property: ',0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'Arrival time: ' .$row->hourarrival,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'Departure time: ' .$row->hourdeparture,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'Arrival flight: ' .$row->arrivalflightdetails,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'Departure flight: ' .$row->departureflightdetails,0,0);
$pdf->Ln(12);
$pdf->SetX(20);
$pdf->Cell(170,5'Services required: (Air Port pickup to be paid on arrival) ',0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5,'Taxi' .SEP.'s up to 4 persons: ' .$row->taxismall,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5,'Taxi'.SEP.'s up to 7 persons: ' .$row->taxibig,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'n'.DEG.' and group of Rent a car'.SEP.'s: ' .$row->rentacar,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'n'.DEG.' of cots (free of charge): ' .$row->cot,0,0);
$pdf->Ln(6);
$pdf->SetX(20);
$pdf->Cell(170,5'Other services: ' .$row->otherservices,0,0);
$pdf->Ln(9);
$pdf->SetFont('Arial','',8);
$pdf->SetX(20);
$pdf->Cell(170,5'All charges of bank transfers to be paid by the guest. If the option of credit or debit card payment is chosen there will be a 4%  charge to the guest.',0,0);
$pdf->Ln(4);
$pdf->Image('footeringles2.png',40,278,140);
}
$pdf->Output("bookings/filename55.pdf","F");
$path "bookings/filename55.pdf"

using this to send with phpmailer:
PHP Code:
 $asunto "$row->propiedad$row->llegada - $row->salida";
$mail->AddAttachment($path$asunto$encoding 'base64'$type 'application/pdf');
if(!
$mail->Send())
{
   echo 
"Message could not be sent, enter a valid e-mail. <p>";
   echo 
"Mailer Error: " $mail->ErrorInfo;
   exit;


Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Send fpdf with phpmailer as an attachment

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap