<?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>Intelligrape  Groovy &#38; Grails Blogs &#187; add cover page to pdf</title>
	<atom:link href="http://www.intelligrape.com/blog/tag/add-cover-page-to-pdf/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.intelligrape.com/blog</link>
	<description></description>
	<lastBuildDate>Thu, 02 Feb 2012 07:48:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
			<title>Intelligrape  Groovy &amp; Grails Blogs</title>
			<url>http://www.intelligrape.com/blog/wp-content/uploads/2011/05/favicon2.ico</url>
			<link>http://www.intelligrape.com/blog</link>
			<width></width>
			<height></height>
			<description></description>
		</image>		<item>
		<title>Merge two PDF files</title>
		<link>http://www.intelligrape.com/blog/2010/07/12/merge-two-pdf-files/</link>
		<comments>http://www.intelligrape.com/blog/2010/07/12/merge-two-pdf-files/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 13:52:50 +0000</pubDate>
		<dc:creator>Uday Pratap Singh</dc:creator>
				<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Java tools]]></category>
		<category><![CDATA[add cover page to pdf]]></category>
		<category><![CDATA[merge pdf with iText]]></category>
		<category><![CDATA[merge two pdf file]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=1211</guid>
		<description><![CDATA[In my current project the user has the option to add pdf file into the system. Recently we got the requirement to add a cover page to each pdf document that user downloads. We were already using the iText API for generating pdf so the task to do that was easy. After going through the [...]]]></description>
			<content:encoded><![CDATA[<p>In my current project the user has the option to add pdf file into the system. Recently we got the requirement to add a cover page to each pdf document that user downloads. We were already using the iText API for generating pdf so the task to do that was easy. After going through the documentation of iText I found a way to merge two pdf files.</p>

<div class="wp_syntax"><div class="code"><pre class="groovy"><span style="color: #000000; font-weight: bold;">try</span><span style="color: #66cc66;">&#123;</span>
            PdfReader pdfReader1 <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PdfReader<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;firstFile.pdf&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
            PdfReader pdfReader2 <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PdfReader<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;secondFile.pdf&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
            PdfCopyFields finalCopy <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PdfCopyFields<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">FileOutputStream</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;finalCopy.pdf&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
            finalCopy.<span style="color: #006600;">open</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
            <span style="color: #66cc66;">&#91;</span>pdfReader1,pdfReader2<span style="color: #66cc66;">&#93;</span>.<span style="color: #663399;">each</span> <span style="color: #66cc66;">&#123;</span>PdfReader pdfReader -<span style="color: #66cc66;">&gt;</span>
                   finalCopy.<span style="color: #006600;">addDocument</span><span style="color: #66cc66;">&#40;</span>pdfReader<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
            <span style="color: #66cc66;">&#125;</span>
            finalCopy.<span style="color: #993399; font-weight: bold;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span>DocumentException e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            e.<span style="color: #006600;">printStackTrace</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">FileNotFoundException</span> e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            e.<span style="color: #006600;">printStackTrace</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">IOException</span> e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            e.<span style="color: #006600;">printStackTrace</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>I hope it helped you <img src='http://www.intelligrape.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>## Uday Pratap Singh ##<br />
uday@intelligrape.com</p>
<p><a href="http://www.IntelliGrape.com/">http://www.IntelliGrape.com/</a><br />
<a href="http://in.linkedin.com/in/meudaypratap">http://in.linkedin.com/in/meudaypratap</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2010/07/12/merge-two-pdf-files/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

