0

I'm working on a web app built with ExtJS on the front end and a Zend Framework 1.12 API for backend. Currently I have reports that are generated in the API with a view script, then presented to the user in an iFrame through ExtJS. I have a print button which easily allows the report to be printed.

Now I want to add a button to be able to email these reports to users as a PDF. I am assuming this would be best handled on the API side.

Really what I am wanting to do is take the report that is generated from the html view, and create a pdf file that can then be attached to an email and sent to a user.

Is this a complicated task?

kc_rob
  • 147
  • 1
  • 9
  • Not really the correct place to be asking this. Probably best off going to http://programmers.stackexchange.com/ However there are PHP libraries which allow you to basically create a PDF straight from the HTML output of your view. Have a look at https://code.google.com/p/dompdf/ for example and this question http://stackoverflow.com/questions/391005/convert-html-css-to-pdf-with-php – Rob Schmuecker Jan 12 '15 at 18:39

1 Answers1

0

Not a complete answer but, yes this can be done using Zend Framework.

Save the pdf document to the server and attach it to the email.

$pdfAtt = new Zend_Mime_Part($pdfDoc);
$pdfAtt->type        = 'application/pdf';
$pdfAtt->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
$pdfAtt->encoding    = Zend_Mime::ENCODING_BASE64;
$pdfAtt->filename    = 'Attatchment.pdf';

$mail = new Zend_Mail

$mail->addTo('email@address.com')
     ->setSubject('PDF Document Attached')
     ->setBodyHTML($mailBody)
     ->setFrom('office@academyphotos.co.uk')
     ->addAttachment($pdfAtt);
Gavin
  • 2,123
  • 1
  • 15
  • 19