/** * Set the file name and manage the email attachement output * * @see TCPDF::Output() */ public function Output($name = "doc.pdf", $dest = 'I') { if (!empty($this->pdfFilename)) { $name = $this->pdfFilename; } // This case is for "email as PDF" if (isset($_REQUEST['to_email']) && $_REQUEST['to_email'] == "1") { // After the output the object is destroy $bean = $this->bean; $tmp = parent::Output('', 'S'); $badoutput = ob_get_contents(); if (strlen($badoutput) > 0) { ob_end_clean(); } file_put_contents('upload://' . $name, ltrim($tmp)); $email_id = $this->buildEmail($name, $bean); //redirect if ($email_id == "") { //Redirect to quote, since something went wrong echo "There was an error with your request"; exit; //end if email id is blank } else { SugarApplication::redirect("index.php?module=Emails&action=Compose&record=" . $email_id . "&replyForward=true&reply="); } } parent::Output($name, 'D'); }