<?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>pieceofpy.com &#187; concatenate</title>
	<atom:link href="http://pieceofpy.com/tag/concatenate/feed/" rel="self" type="application/rss+xml" />
	<link>http://pieceofpy.com</link>
	<description>Another python blog with a love for agile methods.</description>
	<lastBuildDate>Tue, 18 May 2010 15:31:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Concatenating PDF with Python</title>
		<link>http://pieceofpy.com/2009/03/05/concatenating-pdf-with-python/</link>
		<comments>http://pieceofpy.com/2009/03/05/concatenating-pdf-with-python/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 14:33:07 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[concatenate]]></category>
		<category><![CDATA[pdf]]></category>

		<guid isPermaLink="false">http://pieceofpy.com/?p=229</guid>
		<description><![CDATA[I need to concatenate a set of PDFs, I will take you through my standard issue Python development approach when doing something I&#8217;ve never done before in Python.
My first instinct was to google for pyPDF. Success! So, fore go reading any doc and just give the old easy_install a try.

$ sudo easy_install pypdf

Another success! Ok, [...]]]></description>
			<content:encoded><![CDATA[<p>I need to concatenate a set of PDFs, I will take you through my standard issue Python development approach when doing something I&#8217;ve never done before in Python.</p>
<p>My first instinct was to google for pyPDF. Success! So, fore go reading any doc and just give the old easy_install a try.</p>
<pre class="brush: bash">
$ sudo easy_install pypdf
</pre>
<p>Another success! Ok, a couple help() calls later and I am ready to go. The end result is surprisingly small and seems to run fast enough even for PDFs with 50+ pages.</p>
<pre class="brush: py">
from pyPdf import PdfFileWriter, PdfFileReader

def append_pdf(input,output):
    [output.addPage(input.getPage(page_num)) for page_num in range(input.numPages)]

output = PdfFileWriter()
append_pdf(PdfFileReader(file(&quot;sample.pdf&quot;,&quot;rb&quot;)),output)
append_pdf(PdfFileReader(file(&quot;sample.pdf&quot;,&quot;rb&quot;)),output)

output.write(file(&quot;combined.pdf&quot;,&quot;wb&quot;))
</pre>
]]></content:encoded>
			<wfw:commentRss>http://pieceofpy.com/2009/03/05/concatenating-pdf-with-python/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
