<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>James Revillini &#187; php</title>
	<atom:link href="http://james.revillini.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://james.revillini.com</link>
	<description>Say 'no' to styrofoam.</description>
	<lastBuildDate>Fri, 15 Oct 2010 12:24:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>CakePHP 1.1.x, Vendors, and domPDF</title>
		<link>http://james.revillini.com/2008/10/22/cakephp-11x-vendors-and-dompdf/</link>
		<comments>http://james.revillini.com/2008/10/22/cakephp-11x-vendors-and-dompdf/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 18:31:11 +0000</pubDate>
		<dc:creator>james</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[cakephp howto]]></category>

		<guid isPermaLink="false">http://james.revillini.com/?p=108</guid>
		<description><![CDATA[Wow &#8211; for a built in feature, this sure was a pain in the ass to get working.  I&#8217;m talking about using the &#8216;vendors&#8217; functionality in CakePHP 1.1.x (I&#8217;m at .19), of course, and in this case, my external class was domPDF. First of all, they never really cover how to use the vendor function [...]]]></description>
			<content:encoded><![CDATA[<p>Wow &#8211; for a built in feature, this sure was a pain in the ass to get working.  I&#8217;m talking about using the &#8216;vendors&#8217; functionality in CakePHP 1.1.x (I&#8217;m at .19), of course, and in this case, my external class was domPDF.</p>
<p>First of all, they never really cover how to use the vendor function in the CakePHP Docs.  Usually when that happens, it&#8217;s one of those things that&#8217;s so painfully simple, you could get drunk, trip on something and accidentally get it working.</p>
<p>But no &#8211; here&#8217;s what you need to do in plain english.  (<em>HOWTO writers</em> &#8211; please take note that I include like <em>every</em> step and try not to assume too much knowledge on the part of the struggling user.  It would be great if you started writing HOWTOs like this as well.)</p>
<p> </p>
<ol>
<li>download dompdf</li>
<li>extract it to a temp area.  you should have a folder like <strong>dompdf-0.5.1</strong> containing subfolders like &#8216;include&#8217;, &#8216;lib&#8217;, and &#8216;www&#8217;.</li>
<li>rename the dompdf-0.5.1 folder to &#8216;<strong>dompdf</strong>&#8216;</li>
<li>move the <strong>dompdf </strong>folder to your {CAKE_INSTALL}/app/vendors/ directory.</li>
<li>copy and paste my <span style="color: #ff6600;"><strong>sample code</strong></span> (below) into your controller, before the closing <strong>}</strong></li>
<li>upload everything to your webserver, and now try it using a url like http://yoursite.com/cake/posts/pdf</li>
<li>if you get an error, or a blank screen, check your apache server log.  if you see something like <strong>PDFlib exception (fatal): [1202] PDF_set_parameter: Unknown key &#8216;objorient&#8217; </strong>then you need to do one more thing.  
<ol>
<li>open {CAKE_INSTALL}/app/vendors/dompdf/dompdf_config.inc.php</li>
<li>find <strong>define(&#8220;DOMPDF_PDF_BACKEND&#8221;, &#8220;auto&#8221;);</strong></li>
<li><strong><span style="font-weight: normal;">change it to </span>define(&#8220;DOMPDF_PDF_BACKEND&#8221;, &#8220;CPDF&#8221;);</strong></li>
<li>if you want to know why you just did that, it&#8217;s because the PECL PDF library is crashing, or you don&#8217;t have it installed or something.</li>
<li>go back to step 6.</li>
</ol>
</li>
<li>now customize everything to how you need it.</li>
</ol>
<pre>	//the sample code to be pasted into the controller of your choice</pre>
<pre>	function pdf() {
		vendor('dompdf/dompdf_config.inc'); 

		$html =
		  '&lt;html&gt;&lt;body&gt;'.
		  '&lt;p&gt;Put your html here, or generate it with your favourite '.
		  'templating system.&lt;/p&gt;'.
		  '&lt;/body&gt;&lt;/html&gt;';

		$dompdf = new DOMPDF();
		$dompdf-&gt;load_html($html);
		$dompdf-&gt;render();
		$dompdf-&gt;stream("sample.pdf");
		exit();
	}</pre>
]]></content:encoded>
			<wfw:commentRss>http://james.revillini.com/2008/10/22/cakephp-11x-vendors-and-dompdf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

