segy / Mpdf

CakePHP 2.x Component for creating PDF files from HTML using mPDF class
30 stars 19 forks source link

Output 'F' from a function #5

Closed elogicmedia closed 10 years ago

elogicmedia commented 12 years ago

Hi, I cannot seem to get this to work to generate the PDF as a file saved the the server when calling the function that generates the PDF from another, if I load the function in the browser manually it will generate and save.

I'm guessing it has something to do with the view needing to be loaded, any idea how to get around this? I just want the file to save to the server which I will call out elsewhere.

below is my function, I'm calling this from an export function such as: $this->mail_merge($conditions, $theid);

Thanks

mail_merge function // FUNCTION GENERATE MAIL MERGE - mPDF // --------------------------------------------------------------> function mail_merge($conditions=NULL, $mail_merge_id=1) { // REMOVE THE STANDARD LAYOUT // ------------------------------------------------------> $this->layout = null; //$this->autoRender = FALSE; //debug($conditions);

    // GET THE CONTACTS
    // ------------------------------------------------------------->
    $contacts = $this->Contact->Card->find('all', array(
                                                  'limit' => 50, 
                                                  //'fields' => $fields,
                                                'contain' => array('Contact', 'Prospect', 'SaleDetail'),
                                                  'conditions' => $conditions
                                                  ));
    $this->set('contacts', $contacts);
    //debug($contacts);

    // GE THE CONTENTS
    // ------------------------------------------------------------>
    $this->loadModel('MailMerge');
    $content = $this->MailMerge->find('first', array(
                                                'conditions' => array('MailMerge.id' => $mail_merge_id),
                                                'fields' => array('MailMerge.description')
                                                ));
    $this->set('content', $content);

    // initializing mPDF
    $this->Mpdf->init();

    // setting filename of output pdf file
    $thefilename = "mail_merge_".date("d.m.Y_His").".pdf";
    $this->Mpdf->setFilename(APP. WEBROOT_DIR . "/files/csv_exports/" . $thefilename); 

    // setting output to I, D, F, S
    $this->Mpdf->setOutput('F');

    return $thefilename;

} // END MAIL MERGE
segy commented 10 years ago

Hello. Please see updated readme