last day (14 days later) » 

9:04 AM
1
Q: decoding pdf string and sending it by codeigniter email functionality

Masnad NihitI am using dompdf to generate a pdf and I am taking the raw string, encoding it for saving it to the database later and then decoding it so I can send it as a attachment for the email, but I cannot do it anyhow. I tried both the examples here PHP Send email with PDF attachment without creating th...

 
whats output or error??
 
Sends a email without any pdf file attached and $pdf says (resource) resource id='172' type='Unknown'
 
$pdf has null value means ??
 
Sorry it didnt say null it says (resource) resource id='172' type='Unknown'
 
is your pdf get written correctly ??
 
9:04 AM
yup if I just change $dompdf->output(); to $dompdf->stream("$id.pdf", array("Attachment" => false)); I get to see the pdf which is written correctly , but I am taking the string and using that instead of generated pdf
 
i'm unclear with your purpose
 
what I want to do is get the pdf string, and encode it first to store it in the database, and if later I would want to send the pdf as a email I would get the string from the database and decode it and send it as a attachment in the email, like different users might want to get their pdf files multiples times as email.
 
So you have two steps
1. is store text in DB
2. attach file in mail
is it??
 
Yes
and sorry
for the delay
dint see the last message
 
so is first one working ??
 
9:10 AM
Yup
Only the 2nd step is a pain
 
attch pdf to mail. Thts it ??
 
Yup
after decoding it, I thought the pdf will get attached easily but all I get is a empty email
 
add this
$path = set_realpath('uploads/pdf/');
$this->email->attach($path . 'myfile.pdf');
 
what does the set_realpath do ?
and where do I add the codes you
gave me ?
 
$this->email->subject('pdf');
next to this
 
9:16 AM
$this->email->from('support@aurorax.co', 'aurora exchange');
$this->email->to('masnad@aurorax.co');
$this->email->subject('pdf');
$path = set_realpath('uploads/pdf/');
$this->email->attach($path . 'myfile.pdf');
$this->email->message('Your pdf is here');
// $this->email->attach($pdf);
$this->email->send();
so is that right ?
 
set your path uploads/pdf/
 
yea the problem is that, I am not saving the pdf anywhere
besides the database
 
thn you cant attch file ;(
no wayy
is this file get saved credit_agreement.pdf ??
and you attaching tht? is it??
 
No
I am trying to get the string, change it back to pdf then attach it
I was told this piece of code would do it
$pdf_decoded = base64_decode ($pdf_content);
//Write data back to pdf file
$pdf = fopen ('credit_agreement.pdf','w');
fwrite ($pdf,$pdf_decoded);
//close output file
fclose ($pdf);
seeing the other stack overflow
 
what is credit_agreement.pdf
 
9:22 AM
its just a name of the file, its not saved
I was told that you can add whatever name you want
it will write the pdf like that
it could also be
$pdf = fopen ('putsomethingback.pdf','w');
from this link
 
i suggets you to save the file. then attach
 
I Know but the problem is that I was told not to do that in my workplace
so I cant find a solution
hence I am saving it to the database
with the string
 
just upload file
then attach
then delet file
no 1n knws
 
yea I did that before actually but I was told not to, I guess I will search a bit more over in google :D
But thanks for the help
I appreciate it :D
 
(y)
 

last day (14 days later) »