Php mPDF-从另一个函数中调用时不生成PDF

Php mPDF-从另一个函数中调用时不生成PDF,php,cakephp,mpdf,Php,Cakephp,Mpdf,我有一个mail_merge函数(使用cakephp),当直接从浏览器调用它时,例如。 domain.com/contacts/mail_merge将生成PDF,并根据需要使用数据库映射字段将其保存到服务器 然而,当我试图从另一个函数调用此邮件合并函数时。e、 g.$this->mail\u merge($cond,1);PDF不会生成。数据库字段仍在传递给邮件合并函数,因此这不是问题所在。知道为什么会这样吗?我已经更新了我下面的代码,现在包含了一个简单的生成的txt文件,我正试图将代码放在PD

我有一个mail_merge函数(使用cakephp),当直接从浏览器调用它时,例如。 domain.com/contacts/mail_merge将生成PDF,并根据需要使用数据库映射字段将其保存到服务器

然而,当我试图从另一个函数调用此邮件合并函数时。e、 g.$this->mail\u merge($cond,1);PDF不会生成。数据库字段仍在传递给邮件合并函数,因此这不是问题所在。知道为什么会这样吗?我已经更新了我下面的代码,现在包含了一个简单的生成的txt文件,我正试图将代码放在PDF中,这是有效的,因此mPDF的一些东西在从函数调用时不会生成PDF

谢谢

我的邮件合并功能如下:

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

    // GET THE CONTACTS
    // ------------------------------------------------------------->
    $contacts = $this->Contact->Card->find('all', array(
                                                  'limit' => 10, 
                                                  //'fields' => $fields,
                                                'contain' => array('Contact', 'Prospect', 'SaleDetail'),
                                                  'conditions' => $conditions
                                                  ));
    $this->set('contacts', $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();

    // RENDER THE VIEW AND SET AS A VARIABLE TO WRITE THE HTML
    // --------------------------------------------------------------------------->
    $response = $this->render('mail_merge');
    $thebody = $response->body();
    $this->Mpdf->WriteHTML($thebody);

    // 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');

    // TEMP - CREATE TXT FILE ON THE SERVER
    // ------------------------------------------------------------------------>
    $thefilenametxt = "mail_merge_".date("d.m.Y_His").".txt";
    $ourFileHandle = fopen(APP. WEBROOT_DIR . "/files/csv_exports/" . $thefilenametxt, 'w');
    fwrite($ourFileHandle, $thebody); 
    fclose($ourFileHandle); 

    return $thefilename;

} // END MAIL MERGE

我发现问题出在组件的setOutput函数上

当我改变时:

$this->Mpdf->setFilename(APP. WEBROOT_DIR . "/files/csv_exports/" . $thefilename); 
$this->Mpdf->setOutput('F');


它根据需要工作。

我发现问题在于组件的setOutput函数

当我改变时:

$this->Mpdf->setFilename(APP. WEBROOT_DIR . "/files/csv_exports/" . $thefilename); 
$this->Mpdf->setOutput('F');

它按需要工作