<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
  <title>aC forum: Getting the assembled html</title>
  <link>http://www.activecollab.com/forums/topic/5477/</link>
  <description>Recent posts on topic: Getting the assembled html</description>
  <dc:language>en-us</dc:language>
  <pubDate>Wed, 23 May 2012 22:11:07 CDT</pubDate>
  
  <item>
    <link>http://www.activecollab.com/forums/post/24303/#post24303</link>
    <guid>http://www.activecollab.com/forums/post/24303/#post24303</guid>
    <title>Post #5 by Gnat</title>
    <dc:creator>Gnat</dc:creator>
    <description><![CDATA[<p>I tried using the ob_get_contents stuff but the display just outputs straight to the browser so I couldn't get around it.</p>]]></description>
    <pubDate>Mon, 28 Dec 2009 21:44:14 CST</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/24302/#post24302</link>
    <guid>http://www.activecollab.com/forums/post/24302/#post24302</guid>
    <title>Post #4 by Ilija Studen</title>
    <dc:creator>Ilija Studen</dc:creator>
    <description><![CDATA[<p>Maybe you could also &quot;catch&quot; HTML that renderLayout() prints in <a href="http://php.net/manual/en/book.outcontrol.php" target="_blank" rel="nofollow">output buffer</a>. This does not require any new methods to be added to the controller - everything goes into action.</p>]]></description>
    <pubDate>Mon, 28 Dec 2009 21:09:11 CST</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/24301/#post24301</link>
    <guid>http://www.activecollab.com/forums/post/24301/#post24301</guid>
    <title>Post #3 by Gnat</title>
    <dc:creator>Gnat</dc:creator>
    <description><![CDATA[<p>So here's how I managed to do it....<br />
<br />
I created a function print_pdf() and print_estimate() in my controller. They use a common layout. From print_pdf() I've done the following. You can see it calls the print_estimate function which triggers all the necessary smarty code paths etc. Then you can see $pdf = $this-&gt;renderOutput(); Which I've defined locally within my controller, which is basically your renderLayout() however I've swaped the tpl_display for tpl_fetch(). this allows me to output any page to pdf using wkhtmltopdf (webkit gui-less browser). It supports CSS and all that, and is MUCH much less time consuming than building a pdf by scratch via the various PDF php classes out there. Build the template in html and out comes styled pdfs. <br />
<br />
<pre name="code" class="brush: php">    function print_pdf()
    {
        $this-&gt;print_estimate();

        $file = '/tmp/TNDG-ESTIMATE-'.$this-&gt;active_estimate-&gt;getId().'.html'; //tempnam('/tmp','estimate_');
        if(is_file($file))
            unlink($file);

        $pdf_file = '/tmp/TNDG-ESTIMATE-'.$this-&gt;active_estimate-&gt;getId().'.pdf';
        if(is_file($pdf_file))
            unlink($pdf_file);

        $pdf = $this-&gt;renderOutput();

        file_put_contents($file,$pdf);

        if (ob_get_contents())
            die('Some data has already been output, can\'t send PDF file');

        if (headers_sent())
            die('Some data has already been output to browser, can\'t send PDF file');

        header('Content-Description: File Transfer');
        header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
        header('Pragma: public');
        header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
        header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
        // force download dialog
        header('Content-Type: application/force-download');
        header('Content-Type: application/octet-stream', false);
        header('Content-Type: application/download', false);
        header('Content-Type: application/pdf', false);
        // use the Content-Disposition header to supply a recommended filename
        header('Content-Disposition: attachment; filename=&quot;'.basename($pdf_file).'&quot;;');
        header('Content-Transfer-Encoding: binary');

        exec(&quot;/usr/local/bin/wkhtmltopdf $file $pdf_file&quot;);

        $fsize = filesize($pdf_file);

        header('Content-Length: '.$fsize);

        echo file_get_contents($fsize);

        die();
    } // print_pdf</pre></p>]]></description>
    <pubDate>Mon, 28 Dec 2009 15:12:49 CST</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/24260/#post24260</link>
    <guid>http://www.activecollab.com/forums/post/24260/#post24260</guid>
    <title>Post #2 by Ilija Studen</title>
    <dc:creator>Ilija Studen</dc:creator>
    <description><![CDATA[<p>Sorry, this functionality is not built into activeCollab.</p>]]></description>
    <pubDate>Thu, 24 Dec 2009 03:50:42 CST</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/24257/#post24257</link>
    <guid>http://www.activecollab.com/forums/post/24257/#post24257</guid>
    <title>Post #1 by Gnat</title>
    <dc:creator>Gnat</dc:creator>
    <description><![CDATA[<p>Hello,<br />
  I'm wondering if it is possible to get the entire output of another controller/action from a different one.<br />
<br />
  In the frameworks I'm used to I can call getPresentationFor('controller','method') and get the full html it would have output to the browser as a result. I need this for a module we're building.. Is that possible?</p>]]></description>
    <pubDate>Wed, 23 Dec 2009 13:39:05 CST</pubDate>
  </item>
</channel>
</rss>
