开发者

PHP(Zend) & Smarty - problems generating .doc file and http headers

i'm using the Zend Framework and Smarty Template generator on a project, i'm new to this work and also to ZF and Smarty. Anyway, on an action there's a click开发者_如何学Cable link for a .doc report generation. Once clicked, it generates a .doc file using HtmlToDoc class by this method:

$htmltodoc_instance -> createDoc($body ,
                  'filename.doc',
                   TRUE);  
/* the last parameter TRUE means: download or save the file. it set the HTTP headers 
'Content-type: application/octet-stream' and 'Content-Disposition: attachment; 
 filename="..."', forcing the browser to open a download dialog for filename.doc

before that, it has been renderd the current action by

 $this -> view -> obj_to_render = $obj_to_render.

with obj_to_render placed in the view, while $obj_to_render is generally the formatted html code by Smarty template engine. I don't know if it is the cause, but it seems that this cause the problem: the header of .doc download dialog is somehow 'overriden' by the next header of view's rendering, and so the .doc file's output is not succesful. i've tried to put an exit() after createDoc() method call, but it doens help much. output is diferent, but it still doesn't display the informations i need. Anybody know how to divide this two operations and then obtain the right file output? thanks!


public function h2dAction()
{
    $content = '<strong>wow! it\'s alive!</strong>';

    $htmltodoc = new HTML_TO_DOC();
    $htmltodoc->docFile = 'wow.doc';
    @$htmltodoc->createDoc($content, $htmltodoc->docFile, true);
    die;
}

GDocs works fine with this file. cant test on MS Word, i dont have it :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜