<?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>SmartLogic Solutions Blog &#187; Adobe PDF</title>
	<atom:link href="http://blog.smartlogicsolutions.com/category/adobe-pdf/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.smartlogicsolutions.com</link>
	<description>News and updates from the people at SmartLogic Solutions</description>
	<lastBuildDate>Tue, 30 Nov 2010 21:39:14 +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>using active x and javascript to scan from your web app</title>
		<link>http://blog.smartlogicsolutions.com/2008/08/08/using-active-x-and-javascript-to-scan-from-your-web-app/</link>
		<comments>http://blog.smartlogicsolutions.com/2008/08/08/using-active-x-and-javascript-to-scan-from-your-web-app/#comments</comments>
		<pubDate>Fri, 08 Aug 2008 16:57:18 +0000</pubDate>
		<dc:creator>Joseph Jakuta</dc:creator>
				<category><![CDATA[ActiveX]]></category>
		<category><![CDATA[Adobe PDF]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Joseph Jakuta]]></category>

		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/?p=125</guid>
		<description><![CDATA[In the app I had been working on users had to perform a great amount of scanning. In the first few iterations this was done manually, which, of course, lead to lots of user error (namely scanning documents at high resolutions, which clogged the system). It was decided that it was best if our app [...]]]></description>
			<content:encoded><![CDATA[<p>In the app I had been working on users had to perform a great amount of scanning.  In the first few iterations this was done manually, which, of course, lead to lots of user error (namely scanning documents at high resolutions, which clogged the system).  It was decided that it was best if our app to control the scan settings for most users.  So we found three possible Active X controllers available to allow for this functionality.  <a href="http://www.ciansoft.com/" target="new">CianSoft</a>, <a href="http://www.vintasoft.com/vstwain-index.html" target="new">VintaSoft</a>, and <a href="http://www.chestysoft.com/" target="new">ChestySoft</a>.  After a little research we found that VintaSoft didn&#8217;t quite meet our needs and that CianSoft&#8217;s TwainX controller and ChestySoft&#8217;s were eerily similar (it turns out that each company is run by a brother and both products were just different flavors of the same one).  In the end ChestySoft was the one we went with because it allows you to perform posts of the scanned data to the server (and the guy that runs the company is super responsive when you have questions).  </p>
<p><span id="more-125"></span></p>
<p>First there isn&#8217;t too much to get this ActiveX controller up in running in the first place.  There are great examples <a href="http://www.chestysoft.com/ximage/manual.htm#sect2" target="new">here</a> that take you 95% of the way towards getting these up and running.  A few little tricks we learned when setting up the javascript portion of the code are as follows:</p>
<ul>
<li>To set the page size use the following method (the example sets it to letter):

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">      csxi.<span style="color: #660066;">SetTwainLayout</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">8.5</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">11</span><span style="color: #009900;">&#41;</span></pre></div></div>

</li>
<li>Some scanners do not reset to their defaults after a custom scan.  You need to make sure you manually set all default settings before scanning.  A few you may want to set:

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">      csxi.<span style="color: #660066;">UseTwainInterface</span><span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//this makes sure that you are not prompted to change settings</span>
      csxi.<span style="color: #660066;">TwainAutoBright</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
      csxi.<span style="color: #660066;">TwainAutoDeskew</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>When beginning a multipage scan you must run the following three methods:<br/>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">      csxi.<span style="color: #660066;">TwainMultiImage</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
      csxi.<span style="color: #660066;">UseADF</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
      csxi.<span style="color: #660066;">ClearPDF</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
</ul>
<p>One other fun thing we can do with ChestySoft&#8217;s TwainX controller is upload the captured data directly to the server.  To do this in the javascript you need to do the following:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">      Success <span style="color: #339933;">=</span> csxi.<span style="color: #660066;">PostImage</span><span style="color: #009900;">&#40;</span>url<span style="color: #339933;">,</span> file_name<span style="color: #339933;">,</span> param_name<span style="color: #339933;">,</span> graphics_format<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>Success<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">//what to do when success</span>
      <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">//what to do if error - here are recommendations:</span>
        csxi.<span style="color: #660066;">SaveToFile</span><span style="color: #009900;">&#40;</span>path_on_desktop<span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">//write data to desktop if you saved as a graphic; </span>
        csxi.<span style="color: #660066;">WritePDF</span><span style="color: #009900;">&#40;</span>path_on_desktop<span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">//write data to desktop if you saved as a pdf; </span>
      <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Some notes about the preceding code.  <i>url</i> a fully qualified url (including the &#8216;http://&#8217;).  <i>file_name</i> is what will be included as <i>original_filename</i> when you are reading data on the server side.  <i>graphics_format</i> is a enumeration that can be found <a href="http://www.chestysoft.com/ximage/manual.htm#sect19" target="new">here</a>.  </p>
<p>And the best thing is after you click on the button that runs your scan the information uploaded is the same as a standard file upload so you don&#8217;t have to do anything strange at all in ruby.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2010/10/08/testing-ajax-with-testunit/" rel="bookmark" class="crp_title">Testing AJAX with Test::Unit</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/10/15/using-swfobject-to-seamlessly-upgrade-to-flash-player-10/" rel="bookmark" class="crp_title">Using SWFObject to Seamlessly Upgrade to Flash Player 10</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/07/01/microsoft-webdav-opens-document-as-read-only-when-using-railsdav/" rel="bookmark" class="crp_title">Microsoft WebDav opens document as Read-Only when using RailsDav</a></li><li><a href="http://blog.smartlogicsolutions.com/2007/08/21/adobe-onair-bus-tour-baltimore/" rel="bookmark" class="crp_title">Adobe onAIR Bus Tour: Baltimore</a></li><li><a href="http://blog.smartlogicsolutions.com/2007/06/06/eclipse-32-and-out-of-memory-errors/" rel="bookmark" class="crp_title">Eclipse 3.2 and &#8220;Out Of Memory&#8221; errors</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://blog.smartlogicsolutions.com/2008/08/08/using-active-x-and-javascript-to-scan-from-your-web-app/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Merging Adobe PDF&#8217;s and generating a table of contents on the fly using ruby</title>
		<link>http://blog.smartlogicsolutions.com/2008/07/21/adobe-pdfs-and-table-of-contents-on-the-fly/</link>
		<comments>http://blog.smartlogicsolutions.com/2008/07/21/adobe-pdfs-and-table-of-contents-on-the-fly/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 17:06:09 +0000</pubDate>
		<dc:creator>Joseph Jakuta</dc:creator>
				<category><![CDATA[Adobe PDF]]></category>
		<category><![CDATA[Joseph Jakuta]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/?p=101</guid>
		<description><![CDATA[So let&#8217;s say you have some random PDFs and what you want is one PDF that includes all of the original PDF files and a table of contents listing all of the files and the proper page numbers. Well in Ruby it is not too hard to put this together. There are a wealth of [...]]]></description>
			<content:encoded><![CDATA[<p>So let&#8217;s say you have some random PDFs and what you want is one PDF that includes all of the original PDF files and a table of contents listing all of the files and the proper page numbers.  Well in Ruby it is not too hard to put this together.  There are a wealth of plugins, gems, and other ruby software available for manipulating and creating PDFs (a thorough list can be found here &#8211; <a href="http://wiki.rubyonrails.org/rails/pages/HowtoGeneratePDFs" target="new">http://wiki.rubyonrails.org/rails/pages/HowtoGeneratePDFs</a>).  To get this project up and running we are going to use two PDF::Writer (<a href="http://rubyforge.org/projects/ruby-pdf/" target="new">http://rubyforge.org/projects/ruby-pdf/</a>) and PDFTK (<a href="http://www.accesspdf.com/pdftk/" target="new">http://www.accesspdf.com/pdftk/</a>) &#8211; though if you want to get fancier and also include text, html, or xml documents you can use PDF::Htmldoc (<a href="http://htmldoc.rubyforge.org/" target="new">http://htmldoc.rubyforge.org/</a>) which requires Htmldoc to be installed.  Before I do get started though, I also have give thanks to George Anderson over at <a href="http://www.benevolentcode.com/" target="new">Benevolent Code</a> who wrote a lot of similar code on the project which provided me with some great examples.</p>
<p><span id="more-101"></span></p>
<p>In the project that I wrote this for we began by creating a wrapper class for the PDFTK gem mentioned earlier.  The basic shell of the method we will be using accepts a list of files and a a title for the new pdf and begins and ends by creating and removing temp directories respectively.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> PdfTool<span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">PDF::Toolkit</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">concat_and_make_table_of_contents</span><span style="color:#006600; font-weight:bold;">&#40;</span>title, files<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'pdf/writer'</span>
    <span style="color:#9966CC; font-weight:bold;">begin</span>
      tmpdir = make_temp<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#CC00FF; font-weight:bold;">FileUtils</span>.<span style="color:#9900CC;">mkdir</span><span style="color:#006600; font-weight:bold;">&#40;</span>tmpdir<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
       <span style="color:#008000; font-style:italic;">#the rest of the code is going here   </span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> error
      <span style="color:#CC0066; font-weight:bold;">raise</span> error
    <span style="color:#9966CC; font-weight:bold;">ensure</span>
      <span style="color:#CC00FF; font-weight:bold;">FileUtils</span>.<span style="color:#9900CC;">rm</span><span style="color:#006600; font-weight:bold;">&#40;</span>temppath<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Following this we are going to have set up PDF::Writer for creating the table of contents.  Unfortunately PDF::Writer is a bit messy to get going, but we are only going to be creating a table of contents with the simplest format possible so it will not be too bad.  Of course if you are not going to want this hard coded, we could easily rewrite the concat_and_make_table_of_contents so that it takes a hash of formatting variables.  Here is the set up of PDF:Writer as well printing of the title.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">      <span style="color:#0066ff; font-weight:bold;">@text_font</span> = <span style="color:#996600;">&quot;Times-Roman&quot;</span>
      <span style="color:#0066ff; font-weight:bold;">@title_font_size</span> = <span style="color:#006666;">17</span>
      <span style="color:#0066ff; font-weight:bold;">@title_vertical_spacing</span> = <span style="color:#006666;">15</span>
      <span style="color:#0066ff; font-weight:bold;">@page_font_size</span> = <span style="color:#006666;">12</span>
      <span style="color:#0066ff; font-weight:bold;">@page_vertical_spacing</span> = <span style="color:#006666;">8</span>
&nbsp;
      print_pdf = <span style="color:#6666ff; font-weight:bold;">PDF::Writer</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:paper</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;A4&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      print_pdf.<span style="color:#9900CC;">margins_pt</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">36</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#0066ff; font-weight:bold;">@top_heading_font_position</span> = <span style="color:#006666;">10</span>
&nbsp;
      print_pdf.<span style="color:#9900CC;">select_font</span> <span style="color:#0066ff; font-weight:bold;">@text_font</span>
      print_pdf.<span style="color:#9900CC;">text</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;&lt;b&gt;#{title}&lt;/b&gt;&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:font_size</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0066ff; font-weight:bold;">@title_font_size</span>,:justification <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:center</span>,:left <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0066ff; font-weight:bold;">@top_heading_font_position</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      print_pdf.<span style="color:#9900CC;">move_pointer</span><span style="color:#006600; font-weight:bold;">&#40;</span>@title_vertical_spacing<span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Next we need to go through the files and generate the table of contents.  We will have a loop to check that all of the files in the array exist and are PDFs (though this will need to change if you decide to add in html, etc conversion).  Then we are going to start assuming the first page of the first document in the list is page 1 (if you want to include the table of contents in the page count you will mostly likely have to generate the table of contents once, then figure out how many pages is its then regenerate it with the offset &#8211;  but we are simplifying this for this example).  Following that we are going to loop though all of the files, determine the title from the metadata and print the title and the page number for each page.   This will finish up by saving the table of contents to a temp file.  (Note: don&#8217;t be confused we are keeping track of two pdf variables &#8211; pdf which corresponds to PDFTK instances and print_pdf which corresponds to PDF::Writer instances).</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">      files = files.<span style="color:#9900CC;">delete_if</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span> !<span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">exists</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>f<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">mime_type</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>f<span style="color:#006600; font-weight:bold;">&#41;</span> != <span style="color:#996600;">'application/pdf'</span><span style="color:#006600; font-weight:bold;">&#125;</span>
      current_page=<span style="color:#006666;">1</span>
      files.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span>
        pdf = <span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span>f<span style="color:#006600; font-weight:bold;">&#41;</span>
        page_title = <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span>pdf<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:Title</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span> pdf<span style="color:#006600; font-weight:bold;">&#91;</span>:<span style="color:#CC00FF; font-weight:bold;">File</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">basename</span><span style="color:#006600; font-weight:bold;">&#40;</span>f<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
        print_pdf.<span style="color:#9900CC;">text</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;#{page_title} - #{current_page}&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:font_size</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0066ff; font-weight:bold;">@page_font_size</span>,:justification <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;">&#41;</span>
        print_pdf.<span style="color:#9900CC;">move_pointer</span><span style="color:#006600; font-weight:bold;">&#40;</span>@page_vertical_spacing<span style="color:#006600; font-weight:bold;">&#41;</span>
        current_page<span style="color:#006600; font-weight:bold;">+</span>= pdf.<span style="color:#9900CC;">pages</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
      print_pdf.<span style="color:#9900CC;">save_as</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span>tmpdir,<span style="color:#996600;">'toc.pdf'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>You may have noticed one method in the previous code that needs some flushing out.  PDFTK provides accessors for all metadata that can be found in the pdf, you simply pass a symbol or a string to the [] method to retrieve it.  Furthermore you can use PDFTK to access the number of pages in the file by simply calling <i>pages</i>.  </p>
<p>For the last step we are going to concatenate all of the files that were passed in the array with the table of contents.  Again PDFTK will come in handy here.  There is a class method <i>pdftk</i> which will accept any commands that PDFTK will run as an array.  So all we need to do is have the PDFTK invoke the concat method.  Following that we are just going to read the data for the generated file and pass that back before we start rescuing and ensuring code.  This portion is as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">      command = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span>tmpdir,<span style="color:#996600;">'toc.pdf'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">+</span> files <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'cat'</span>,<span style="color:#996600;">'output'</span>,<span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span>tmpdir, <span style="color:#996600;">'outfile.pdf'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
      <span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#CC00FF; font-weight:bold;">IOError</span>, <span style="color:#996600;">&quot;Unknown PDFTK Error command: pdftk #{command.join(' ')}&quot;</span> <span style="color:#9966CC; font-weight:bold;">unless</span> pdftk<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">*</span>command<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
      data = <span style="color:#0000FF; font-weight:bold;">nil</span>
      <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span>tmpdir, <span style="color:#996600;">'outfile.pdf'</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#996600;">'r'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span> data = f.<span style="color:#9900CC;">read</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
      <span style="color:#0000FF; font-weight:bold;">return</span> data</pre></div></div>

<p>So now we have a simple method for concatenating and creating a table of contents for several PDF files.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2008/06/02/new-acrobatcom-and-reader-9/" rel="bookmark" class="crp_title">New Acrobat.com and Reader 9</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/07/09/reading-and-replacing-text-in-word-docx-and-excel-xlsx-documents-using-ruby/" rel="bookmark" class="crp_title">Reading and replacing text in Word DocX and Excel XlsX documents using Ruby</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/08/08/using-active-x-and-javascript-to-scan-from-your-web-app/" rel="bookmark" class="crp_title">using active x and javascript to scan from your web app</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/06/13/ruby-on-rails-polymorphic-association-benchmarks/" rel="bookmark" class="crp_title">Ruby on Rails Polymorphic Association Benchmarks</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/08/04/introducing-environmentalize-an-intuitive-environment-focused-config-structure-for-your-rails-applications/" rel="bookmark" class="crp_title">Introducing environmentalist: an intuitive, environment-focused config structure for your rails applications</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://blog.smartlogicsolutions.com/2008/07/21/adobe-pdfs-and-table-of-contents-on-the-fly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

