<?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; ActiveX</title>
	<atom:link href="http://blog.smartlogicsolutions.com/category/activex/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>
	</channel>
</rss>

