<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Brandensilva.com | Web &amp; Mobile Interface Designer » Blog</title>
	
	<link>http://www.brandensilva.com</link>
	<description>Creative, Geek, &amp; Internet Whiz</description>
	<lastBuildDate>Sat, 12 May 2012 03:01:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Brandensilva" /><feedburner:info uri="brandensilva" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>Brandensilva</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Creativity amped with business cards</title>
		<link>http://feedproxy.google.com/~r/Brandensilva/~3/pMbA7i1-rx4/</link>
		<comments>http://www.brandensilva.com/design/creativity-amped-with-business-cards/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 15:39:45 +0000</pubDate>
		<dc:creator>Branden Silva</dc:creator>
				<category><![CDATA[Design]]></category>

		<guid isPermaLink="false">http://www.brandensilva.com/?p=252</guid>
		<description><![CDATA[I had a great time participating in Meredith Marsh&#8216;s Business Card Exchange. I believe this is the second year she has done this and its a nice way to learn of other designers in the industry and perhaps network out and become friends with other talented people in the design community. However not everyone is [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-thumbnail wp-image-282 alignnone" style="padding-left: 10px; padding-top: 15px; float: right;" title="Meredith" src="http://www.brandensilva.com/wp-content/uploads/2010/06/Meredith-150x150.png" alt="" width="150" height="150" /></p>
<p>I had a great time participating in <a href="http://www.twitter.com/meredithmarsh">Meredith Marsh</a>&#8216;s Business Card Exchange. I believe this is the second year she has done this and its a nice way to learn of other designers in the industry and perhaps network out and become friends with other talented people in the design community.</p>
<p>However not everyone is keen to seeing what the benefit is in participating so I figured I&#8217;d share some tips on what to look for to amp up your creativity and get the most out of these business card exchanges.</p>
<h2>Engage the design community</h2>
<div id="attachment_311" class="wp-caption aligncenter" style="width: 521px"><img class="size-full wp-image-311    " style="width: 511;" title="Engage the design community" src="http://www.brandensilva.com/wp-content/uploads/2010/06/engagecommunity.jpg" alt="" width="511" height="146" align="aligncenter" /><p class="wp-caption-text">A few of the 2010 business card exchange participants</p></div>
<p>Engaging the design community allows you to extend your reach with existing and fresh talent in the design communities. By allowing yourself to meet others who may or may not be more experienced than you, increases your awareness of web trends and allows for a different perspective of creativity. In fact just by participating in the business card exchange a few designers added me and some left some nice comments about my site and business cards. These are people I probably would have never met otherwise so you can see how easy it is for the community to equally engage you back. You never know if an opportunity will come along that could increase your goals as a web or graphics designer so never be hesitant about joining in on these designer business card exchanges.</p>
<h2>Recognize the trends</h2>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-321" title="Recognize the trends" src="http://www.brandensilva.com/wp-content/uploads/2010/06/trendydesign.jpg" alt="" width="550" height="250" /></p>
<p>It&#8217;s easy to side track the importance of keeping up with trends in the design community. The problem is if you don&#8217;t keep up, you usually fall behind and eventually get weeded out of the market quickly as time progresses. It ultimately depends on the client but clients aren&#8217;t going to be as big of risk takers as you are in their design processes for business cards. They want something thats standard, works, and brings in more visitors to sell their product or service. However, when you are participating with other designers you can be more free in expressing yourself and show off your skills. I personally enjoyed the business cards that kept things clean, simple, and light as this seems to be an emerging trend on the web as of late. Perhaps its because its easier to maintain or because of faster loading times; either way, its a win win for the designer and the user.</p>
<p>Here are a some of the minimalistic cards I enjoyed out of the bunch:</p>
<p><img class="alignleft size-full wp-image-307" title="2010 Business Card Exchange" src="http://www.brandensilva.com/wp-content/uploads/2010/06/business-card-favs.jpg" alt="" width="550" height="366" /></p>
<p>Of course there are a ton of other good designers in the list with different styles which aren&#8217;t listed here but this article isn&#8217;t intended to go into detail about the various design styles. Just be aware of the trends you see other designers doing and see if you can creep in some of that sweet design action into your own designs in the future.</p>
<h2>Include your social networks</h2>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-323" title="Include your social icons" src="http://www.brandensilva.com/wp-content/uploads/2010/06/socialicons.jpg" alt="" width="550" height="128" /></p>
<p>This seems like a no brainer right? However I noticed others, including myself (doh!), haven&#8217;t done this. They may have been trying to keep things less cluttered which is definitely a goal to keep in mind for a business card but I found that the business cards that got the biggest reaction for me were the ones I could add to my social networks. After all in the context of this design business card exchange I&#8217;m less inclined to email someone on a business card and more likely going to add them to social networks to keep tabs on their work. It&#8217;s important to note however that traditional businesses still favor email, but new and online businesses definitely favor social networks and fast communication. Twitter was the winner in this batch of cards, but facebook or linkedin wouldn&#8217;t be a bad thing to add either if you are looking to expand your social reach.</p>
<h2>Just Have Fun With It</h2>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-325" title="Just have fun with it" src="http://www.brandensilva.com/wp-content/uploads/2010/06/merry-go-round.jpg" alt="" width="550" height="354" /></p>
<p>Business card exchanges wouldn&#8217;t be that awesome if you didn&#8217;t have others to share your creations with. It&#8217;s probably one of the only times you aren&#8217;t being limited in creative freedom by adhering to client requirements and web standards. So don&#8217;t get bogged down thinking it is just another project. Have fun with it and don&#8217;t forget to make some new friendships along the way.</p>
<h2>Other Resources</h2>
<p>Check out some of these other bloggers discussing the 2010 business card exchange this year.</p>
<ul>
<li><a href="http://vimeo.com/9952563" target="_blank">Meredith Marsh&#8217;s 2010 Business Card Exchange Video Post</a></li>
<li><a href="http://blog.jeffstyle.com/2010/06/07/meredith-marsh-bizx/" target="_blank">Jeff Lin&#8217;s Merdith Marsh&#8217;s Business Card Exchange Post</a></li>
<li><a href="http://www.small-business-graphic-design.com/examples-of-business-cards.html" target="_blank">Rhonda Brown&#8217;s 70 Examples of Business Cards from 70 Creative People Post</a></li>
<li><a href="http://blog.steventrotter.com/2010/06/07/meredithmarshs-bizx-ftw/" target="_blank">Steven Trotter&#8217;s @merdithmarsh #bizx FTW Post</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/Brandensilva/~4/pMbA7i1-rx4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.brandensilva.com/design/creativity-amped-with-business-cards/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.brandensilva.com/design/creativity-amped-with-business-cards/</feedburner:origLink></item>
		<item>
		<title>Create a PDF invoice using Prawn in Rails</title>
		<link>http://feedproxy.google.com/~r/Brandensilva/~3/DOyCMycZFuI/</link>
		<comments>http://www.brandensilva.com/rails/create-a-pdf-invoice-using-prawn-in-rails/#comments</comments>
		<pubDate>Tue, 18 May 2010 15:26:44 +0000</pubDate>
		<dc:creator>Branden Silva</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.brandensilva.com/?p=92</guid>
		<description><![CDATA[After coming to the realization that I was going to need to create PDFs on the fly for the rails application I&#8217;m working on for a client, I started my hunt for something that could get the job done quick with minimal effort. I&#8217;m in no way a full-time rails developer yet, but I&#8217;m slowly [...]]]></description>
			<content:encoded><![CDATA[<p>After coming to the realization that I was going to need to create PDFs on the fly for the rails application I&#8217;m working on for a client, I started my hunt for something that could get the job done quick with minimal effort. I&#8217;m in no way a full-time rails developer yet, but I&#8217;m slowly working on getting out of the amateurs and <a title="Prawn" href="http://wiki.github.com/sandal/prawn/" target="_blank">Prawn </a>gem was highly recommended by other rails enthusiasts.</p>
<p>Perhaps the greatest gripe I had about Prawn on first encounter was the lack of being able to use CSS &amp; HTML for easy styling, which is something I&#8217;m much more comfortable with from experience. But after realizing that there weren&#8217;t many candidates that allowed this type of styling format in PDFs, I decided to give Prawn a go anyhow.</p>
<p>I also found <a title="prawnto" href="http://www.cracklabs.com/prawnto" target="_blank">prawnto</a> googling, which is a plugin used with Prawn to provide easy access to the prawn library and allows for a simple respond_to block slapped into your controller to provide you with the .pdf extension. This seemed perfect for what I needed so I figured I&#8217;d share my knowledge with others so lets get started.</p>
<h2>Let&#8217;s create a rails <em>customer</em> project</h2>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#008000; font-style:italic;"># Create a rails project</span><br />
rails customer<br />
<br />
<span style="color:#008000; font-style:italic;"># Change directories to our project</span><br />
cd customer</div></div>
<p>Let&#8217;s do some scaffolding to save some time. In this case we are going to create invoices for our customers.</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#008000; font-style:italic;"># Scaffold an invoice for our customer</span><br />
script<span style="color:#006600; font-weight:bold;">/</span>generate scaffold invoice customer_name:<span style="color:#CC0066; font-weight:bold;">string</span> item_name:<span style="color:#CC0066; font-weight:bold;">string</span> item_price:<span style="color:#CC0066; font-weight:bold;">string</span> item_qty:<span style="color:#CC0066; font-weight:bold;">integer</span><br />
<br />
<span style="color:#008000; font-style:italic;"># Migrate your database</span><br />
rake db:migrate</div></div>
<p>Launch your server:</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">script<span style="color:#006600; font-weight:bold;">/</span>server</div></div>
<p>Time to create a new customer invoice that we can work with. Go to your <em>http://localhost:3000/invoices</em> page and click on <em>new invoice</em> and add some data; here is what I used:</p>
<p>Name: Branden Silva<br />
Item Name: Awesome Serif Fonts<br />
Item Price: 24.99<br />
Item Quantity: 2</p>
<p>Once done, <em>http://localhost:3000/invoice/1</em> should now be your first customer invoice. Awesome, now lets get prawn &amp; prawnto installed.</p>
<h2>Getting prawn &amp; prawnto up and running</h2>
<p>I&#8217;m using <em>rails 2.3.5</em> for reference so your results may vary depending on what version you are running. First you&#8217;ll want to download the prawn gem and prawnto plugin into your project like so:</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color:#008000; font-style:italic;"># Install Prawn Gem</span><br />
sudo gem install prawn<br />
<br />
<span style="color:#008000; font-style:italic;"># Install Prawnto Plugin</span><br />
script<span style="color:#006600; font-weight:bold;">/</span>plugin install git:<span style="color:#006600; font-weight:bold;">//</span>github.<span style="color:#9900CC;">com</span><span style="color:#006600; font-weight:bold;">/</span>thorny<span style="color:#006600; font-weight:bold;">-</span>sun<span style="color:#006600; font-weight:bold;">/</span>prawnto.<span style="color:#9900CC;">git</span></div></div>
<p><strong>Note</strong>: If you end up getting a &#8220;uninitialized constant Mime::PDF&#8221; error further down the tutorial when launching the pdf then prawnto may have not installed correctly. I recommend you go download prawnto at the git repository <a href="http://github.com/thorny-sun/prawnto">here</a> and create a folder <em>prawnto</em> under your <em>vendor/plugins</em> directory in your rails application and stash the files in there.</p>
<p>Then your going to want to add prawn to your <em>environment.rb</em> file to avoid any dependency issues in the future:</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#008000; font-style:italic;"># Add this line to your config/environment.rb file.</span><br />
config.<span style="color:#9900CC;">gem</span> <span style="color:#996600;">&quot;prawn&quot;</span></div></div>
<p>Then you are going to have to set up prawnto in your <em>invoice</em> controller. Here I&#8217;m going to fetch a customer invoice and display a pdf in my show action when a user adds a .pdf extension to the url. The part you&#8217;ll want to pay attention to and add is the <em>format.pdf</em> line.</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color:#008000; font-style:italic;"># invoices/show</span><br />
<span style="color:#9966CC; font-weight:bold;">def</span> show<br />
<span style="color:#0066ff; font-weight:bold;">@invoice</span> = Invoice.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:id</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
respond_to <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span><span style="color:#CC0066; font-weight:bold;">format</span><span style="color:#006600; font-weight:bold;">|</span><br />
<span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">html</span> <span style="color:#008000; font-style:italic;"># show.html.erb</span><br />
<span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">xml</span> &nbsp;<span style="color:#006600; font-weight:bold;">&#123;</span> render <span style="color:#ff3333; font-weight:bold;">:xml</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0066ff; font-weight:bold;">@invoice</span> <span style="color:#006600; font-weight:bold;">&#125;</span><br />
<span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">pdf</span> <span style="color:#006600; font-weight:bold;">&#123;</span> render <span style="color:#ff3333; font-weight:bold;">:layout</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">false</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#008000; font-style:italic;"># Add this line</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<p>Now your going to need to create a file to put your prawn code into. In this case I just create a blank <em>show.pdf.prawn</em> file under the <em>http://localhost:3000/views/invoices</em> folder.</p>
<h2>Now it&#8217;s time to start dishing some prawn</h2>
<p>Lets start writing some prawn code. You can access your PDF at any time by simply adding a .pdf extension to your individual customer invoices. So <em>http://localhost:3000/invoices/1</em> is how you show your customer invoice information via the browser and <em>http://localhost:3000/invoices/1.pdf</em> would be how you access your customer invoice via PDF format. Of course it&#8217;s not going to do anything until we write some code so open up your <em>show.pdf.prawn</em> file.</p>
<p>I usually start off by adding an image to my pdfs to give them a nice spiffy look. Here is the awesome logo I&#8217;m going to use:</p>
<div id="attachment_163" class="wp-caption aligncenter" style="width: 310px"><img class="size-full wp-image-163" title="awesomecompany" src="http://www.brandensilva.com/wp-content/uploads/2010/05/awesomecompany.jpg" alt="" width="300" height="160" /><p class="wp-caption-text">Awesome Company</p></div>
<p>Now save your logo (or mine) to your <em>public/images</em> directory in your rails app. This way you can reference it in your show.pdf.prawn file. Here is what the code looks like in our show.pdf.prawn file to add this image:</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#008000; font-style:italic;"># Assign the path to your file name first to a local variable.</span><br />
logopath = <span style="color:#996600;">&quot;#{RAILS_ROOT}/public/images/awesomecompany.jpg&quot;</span><br />
<br />
<span style="color:#008000; font-style:italic;"># Displays the image in your PDF. Dimensions are optional.</span><br />
pdf.<span style="color:#9900CC;">image</span> logopath, <span style="color:#ff3333; font-weight:bold;">:width</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">197</span>, <span style="color:#ff3333; font-weight:bold;">:height</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">91</span></div></div>
<p>We are simply creating a local variable called <em>logopath</em> and then displaying it with the <em>pdf.image</em> method off our pdf object. I&#8217;ve also set the width and height of the image here.</p>
<p>How about we add some text now to our PDF. First lets shift the page down 70 points, add some styling, and then we can access our lovely instance variables that come with our rails app to pull in dynamic data.</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">pdf.<span style="color:#9900CC;">move_down</span> <span style="color:#006666;">70</span><br />
<br />
<span style="color:#008000; font-style:italic;"># Add the font style and size</span><br />
pdf.<span style="color:#9900CC;">font</span> <span style="color:#996600;">&quot;Helvetica&quot;</span><br />
pdf.<span style="color:#9900CC;">font_size</span> <span style="color:#006666;">18</span><br />
pdf.<span style="color:#9900CC;">text_box</span> <span style="color:#996600;">&quot;Invoice # #{@invoice.id}&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:align</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:right</span><br />
<br />
pdf.<span style="color:#9900CC;">font_size</span> <span style="color:#006666;">22</span><br />
pdf.<span style="color:#9900CC;">text</span> <span style="color:#996600;">&quot;Thank you for your order, #{@invoice.customer_name}.&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:align</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:center</span><br />
pdf.<span style="color:#9900CC;">move_down</span> <span style="color:#006666;">20</span><br />
<br />
pdf.<span style="color:#9900CC;">font_size</span> <span style="color:#006666;">14</span><br />
pdf.<span style="color:#9900CC;">text</span> <span style="color:#996600;">&quot;Below you can find your order details. We hope you shop with Awesome Company again in the future. Now unleash those fonts like hell have no fury!&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:align</span><span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:center</span></div></div>
<p>Thats a big chuck of code so let me break it down for you. <em>pdf.move_down</em> shifts your cursor focus down the PDF document. This doesn&#8217;t apply to our pdf.text_box which is entirely different creature that doesn&#8217;t follow the normal pdf page flow (you can think of text_boxes like absolute divs in html). <em>pdf.font</em> allows you to use supported prawn fonts. I&#8217;m sure it can be extended but I haven&#8217;t researched it in depth because Helvetica fits my needs for this example and client project. <em>pdf.font_size</em> adjusts the size of your text.</p>
<p>So what would we you do if you needed a table? Simple enough, try this:</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">invoiceinfo = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;Item Name&quot;</span>, <span style="color:#996600;">&quot;#{@invoice.item_name}&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;Item Price&quot;</span>, <span style="color:#996600;">&quot;#{@invoice.item_price}&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;Item Quantity&quot;</span>, <span style="color:#996600;">&quot;#{@invoice.item_qty}&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
<br />
pdf.<span style="color:#9900CC;">move_down</span> <span style="color:#006666;">30</span><br />
<br />
pdf.<span style="color:#9900CC;">table</span> invoiceinfo,<br />
<span style="color:#ff3333; font-weight:bold;">:border_style</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:grid</span>,<br />
<span style="color:#ff3333; font-weight:bold;">:font_size</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">11</span>,<br />
<span style="color:#ff3333; font-weight:bold;">:position</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:center</span>,<br />
<span style="color:#ff3333; font-weight:bold;">:column_widths</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006666;">0</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">150</span>, <span style="color:#006666;">1</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">250</span><span style="color:#006600; font-weight:bold;">&#125;</span>,<br />
<span style="color:#ff3333; font-weight:bold;">:align</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006666;">0</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:right</span>, <span style="color:#006666;">1</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:left</span>, <span style="color:#006666;">2</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:right</span>, <span style="color:#006666;">3</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:left</span><span style="color:#006600; font-weight:bold;">&#125;</span>,<br />
<span style="color:#ff3333; font-weight:bold;">:row_colors</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;d2e3ed&quot;</span>, <span style="color:#996600;">&quot;FFFFFF&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span></div></div>
<p>Here we are creating a multi-dimensional array and assigning it values from our rails application. In this case our local variable <em>invoiceinfo</em> is storing our table information. You don&#8217;t have to put the information in it&#8217;s own variable but I find its easier to keep the data separate from the formatting of the table. <em>#{@invoice.item_name}</em> would pull our item name from our rails application and display it in our pdf, yeah, it&#8217;s that easy. <em>pdf.table</em> calls invoiceinfo and then assigns a few attributes to that table. Pretty awesome that it&#8217;s that clean and simple to style everything up with a few key value pairs. I&#8217;ve even added some row colors to make it easier to scan for the user.</p>
<p>However, a PDF wouldn&#8217;t be complete without allowing page numbers. Fairly straightforward to do in prawn as well, here is the code:</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">pdf.<span style="color:#9900CC;">font_size</span> <span style="color:#006666;">14</span><br />
<br />
pdf.<span style="color:#9900CC;">bounding_box</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span>pdf.<span style="color:#9900CC;">bounds</span>.<span style="color:#9900CC;">right</span> <span style="color:#006600; font-weight:bold;">-</span> <span style="color:#006666;">50</span>,pdf.<span style="color:#9900CC;">bounds</span>.<span style="color:#9900CC;">bottom</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#ff3333; font-weight:bold;">:width</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">60</span>, <span style="color:#ff3333; font-weight:bold;">:height</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">20</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
pagecount = pdf.<span style="color:#9900CC;">page_count</span><br />
pdf.<span style="color:#9900CC;">text</span> <span style="color:#996600;">&quot;Page #{pagecount}&quot;</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<p>Here we shrink the <em>pdf.font_size</em> down so the page number won&#8217;t be enormous. We start to get into the <em>pdf.bounding_box</em> creature. You can basically define boxes inside your pdf. In this case we are telling the bounding_box to find the right most edge (bounds) of the box you are in, which happens to be the pdf document, then we subtract 50 points. We do the same thing with the bottom minus the shift of 50 points. We then slap a width and height to our bounding box and perform a block of code in the bounding_box. the local variable <em>pagecount </em> is assigned and then displayed with <em>pdf.text</em>.</p>
<p>Heres my final example for <a href="http://www.brandensilva.com/wp-content/uploads/2010/05/1.pdf">download</a>.</p>
<p>Well there you have it; a simple invoice with very little effort. With some additional research you can add more data and style it further to fit your needs. Before you go though lets add a nice link to our PDF on our main show page so the customer can find it without having to type it in the URL manually. Head over to your <em>views </em>folder and open your <em>http://localhost:3000/invoices/show.html.erb</em> file. Then you&#8217;ll want to add this code somewhere in your file:</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#006600; font-weight:bold;">&lt;%</span>= link_to <span style="color:#996600;">&quot;PDF Invoice&quot;</span>, invoice_path<span style="color:#006600; font-weight:bold;">&#40;</span>@invoice, :<span style="color:#CC0066; font-weight:bold;">format</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'pdf'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">%&gt;</span></div></div>
<p>We&#8217;re basically just calling the invoices path and throwing it the invoice with an extension of pdf attached to the end of it. This should show up as a link now so when your customer clicks on it they will be redirected to the PDF version of your data in your rails application.</p>
<h2>Conclusion</h2>
<p>Prawn is definitely a simple and easy way to get PDFs up and going with very minimal effort. The only downsides I&#8217;ve noticed from my perspective is it&#8217;s not completely possible to style ever nook and cranny because your at the whims of Prawns formatting options; but I&#8217;m guessing it won&#8217;t make much of a difference because there aren&#8217;t to many alternatives as nice as Prawn or that have this simple functionality. Documentation was available, but examples were limited but nothing a Google search can&#8217;t net you. Hopefully this helps out some of those in pursuit of a quick PDF solution.</p>
<p><strong>Final Note:</strong>prawnto&#8217;s website mentions it only been updated to rails 2.2 but I had no problems getting it to work on 2.3.5. It may however be broken in rails 3 so just be aware of that when upgrading.</p>
<h2>Other Resources</h2>
<ul>
<li><a href="http://wiki.github.com/sandal/prawn/" target="_blank">Prawn Github</a></li>
<li><a href="http://cracklabs.com/prawnto" target="_blank">Prawnto Site</a></li>
<li><a href="http://railscasts.com/episodes/153-pdfs-with-prawn" target="_blank">Ryan Bates Railscasts #153</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/Brandensilva/~4/DOyCMycZFuI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.brandensilva.com/rails/create-a-pdf-invoice-using-prawn-in-rails/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://www.brandensilva.com/rails/create-a-pdf-invoice-using-prawn-in-rails/</feedburner:origLink></item>
		<item>
		<title>Hey it’s the new kid on the block</title>
		<link>http://feedproxy.google.com/~r/Brandensilva/~3/uNPGXwNc3PY/</link>
		<comments>http://www.brandensilva.com/personal/hey-its-thenew-kid-on-the-block/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 10:15:56 +0000</pubDate>
		<dc:creator>Branden Silva</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://www.brandensilva.com/?p=1</guid>
		<description><![CDATA[Okay I&#8217;m not that kind of new kid on the block from the 1980&#8242;s pop band, but rather a new creative and technical geek on the prowl for clients. I&#8217;ve finally gotten up the nerve to move onward with my inner awesomeness of creativity and am now expanding myself into the internet realm of business [...]]]></description>
			<content:encoded><![CDATA[<p>Okay I&#8217;m not that kind of new kid on the block from the 1980&#8242;s pop band, but rather a new creative and technical geek on the prowl for clients. I&#8217;ve finally gotten up the nerve to move onward with my inner awesomeness of creativity and am now expanding myself into the internet realm of business and design.</p>
<h2>The Starter Kit</h2>
<p>I started my creative business, <strong>Valiant Designs</strong>, in late 2009 as I was finishing up my Information Technology degree in college. College didn&#8217;t leave me much time to actually hunt for clients, but that didn&#8217;t stop me from drifting my way into the creative field in any way I could; hence the reason why I spawned my iphone application, <a href="http://www.reactivegears.com" target="_blank">Rebate Tracker</a>, for the masses in December of that year. Of course I&#8217;ve been designing much longer, but unprofessionally and as a hobby. I&#8217;m happy to now be opening my doors to clients who want to bring a beautiful and engaging experience to their users.</p>
<p>I&#8217;ve always had a technical background in Windows, Linux, and just about any other internet geeky thing you can think of. I&#8217;ve been active on then internet for about 13 years now and in internet years that makes me like your grandpa. To add insult to injury, I was that geeky kid in high school trying to convince people to use mp3s instead of cds and ever since I laid my, now keyboard-deformed fingers on a keyboard, I&#8217;ve been in love with digital bits ever since. My family laughs at me for telling them I love technology, but when you start to realize just how much of a role technology plays in society, you can&#8217;t help but magnetize your eyeballs to the glowing rectangles that tap you into the world in seconds.</p>
<p>It&#8217;s important to note that I love learning and I am a self-taught designer and coder. I actually started with HTML and QBASIC and migrated my way up to other languages like visual basic, delphi, C++, C#, PHP, and MYSQL. Although I&#8217;m not a fluent programmer, I&#8217;ve now settled my future coding endeavors in ruby and rails and plan to spend the next couple of years striving to be an awesome code jedi like so many other talented individuals in the field. But the picture would not be complete unless I was designing because of the creative ideas, concepts, and pings bouncing around in my skull need a canvas and a destination. I started my battle in Adobe Photoshop 5 and other Adobe (Macromedia at the time) products to become a better skilled <em>craftsman </em>over time. I&#8217;ve come to enjoy typography, grids, and the birth of CSS as the internet has taken shape from table hell to creative bliss. I hope this blog can be room for my creativity to grow and expand into other areas where I can assimilate into a versatile creative and share with the design community as I journey into the unknown.</p>
<h2>What is the plan, stan?</h2>
<p>Because I plan on expanding beyond just client work and into my own design endeavors, I&#8217;ve kept my goals light in terms of client or spec work. But eventually I&#8217;d like to shape Valiant Designs into so much more. Here is a list of goals I&#8217;ve planned out this year:</p>
<ol>
<li>Rather than specifics on how many clients I can find, I aim to bring in $15,000 to $20,000 in terms of client work. It&#8217;s not much but definitely achievable with my skill set and willingness to succeed.</li>
<li>Launch one Ruby on Rails side project of mine. I&#8217;ll also be learning as I go so it will take awhile longer than if I was hot stuff like <a href="http://twitter.com/wycats" target="_blank">@wycats</a> or <a href="http://twitter.com/rbates" target="_blank">@rbates</a>.</li>
<li>Continue to expand my knowledge into the mobile realm of design and development work. My particular focus will be the iPhone, iPad, and Android platforms for now, but I&#8217;d like to eventually cover other major mobile markets.</li>
<li>Continue to share with the design community through blogging regularly and working with other talented designers or developers. Perhaps get involved in some open source projects if time permits it.</li>
<li>Release a WordPress theme or two, along with other educational goodies that go along with it.</li>
<li>Seek partnerships with other talented folks in design or development work.</li>
<li>Release some blog articles to major blogs in the design and development community to expand my presence.</li>
<li>Continue to grow in social media and other forms of communication because people are ultimately more important to me than profits.</li>
</ol>
<p>Some may feel my goal list is light and not edgy enough, but I would reply to that with it is my first year in business and I still have a lot of learning to do in terms of business, contracts, and client work. I&#8217;m also a life long student and jump around often in terms of learning and my career. I enjoy taking time off of work and spending it learning about life or contributing towards societal education and change. I&#8217;m actually in the first stages of putting together a creative documentary about such ideals now in hopes of providing awareness to others.</p>
<p>In the mean time however I look forward to contributing the creative community and to share my creative juices whenever I get the chance.</p>
<img src="http://feeds.feedburner.com/~r/Brandensilva/~4/uNPGXwNc3PY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.brandensilva.com/personal/hey-its-thenew-kid-on-the-block/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.brandensilva.com/personal/hey-its-thenew-kid-on-the-block/</feedburner:origLink></item>
	</channel>
</rss>

