<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Murad's search blog</title><link>http://blogs.msdn.com/b/murads/</link><description>Everything is Search</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>Using jQuery and jqplot in your display template to show a piechart refiner</title><link>http://blogs.msdn.com/b/murads/archive/2013/03/01/using-jquery-and-jqplot-in-your-display-template-to-show-a-piechart-refiner.aspx</link><pubDate>Fri, 01 Mar 2013 09:11:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10398131</guid><dc:creator>Murad Sæter</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/murads/rsscomments.aspx?WeblogPostID=10398131</wfw:commentRss><comments>http://blogs.msdn.com/b/murads/archive/2013/03/01/using-jquery-and-jqplot-in-your-display-template-to-show-a-piechart-refiner.aspx#comments</comments><description>&lt;p&gt;With the display templates in SharePoint 2013 being built in html and javascript you can easily re-use exisiting javascript frameworks like jQuery.&lt;/p&gt;
&lt;p&gt;The &lt;a title="jQuery" href="http://jquery.com/" target="_blank"&gt;jquery&lt;/a&gt; plugin called &lt;a title="jqPlot Charts and Graphs for jQuery" href="http://www.jqplot.com/" target="_blank"&gt;jqplot&lt;/a&gt; is one of many charting plugins available. It is more or less randomly chosen and the technique shown in this post can be re-used with many other plugins available.&lt;/p&gt;
&lt;p&gt;Using the piechart available in jqplot can make your refiner look like below:&lt;/p&gt;
&lt;h1&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85-metablogapi/3414.jqplot_5F00_refiner_5F00_0EDCC77B.png"&gt;&lt;img style="display: inline;" title="jqplot_refiner" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85-metablogapi/3414.jqplot_5F00_refiner_5F00_thumb_5F00_3F8FCF26.png" alt="jqplot_refiner" width="217" height="244" border="0" /&gt;&lt;/a&gt;&lt;/h1&gt;
&lt;h2&gt;&amp;nbsp;&lt;/h2&gt;
&lt;p&gt;The display templates used for refiners are located in the master page gallery, in folder &amp;ldquo;Filters&amp;rdquo; in the &amp;ldquo;Display Templates&amp;rdquo; folder. For more information about display templates, have a look a Steve Peschka&amp;rsquo;s article &lt;a href="http://blogs.technet.com/b/speschka/archive/2012/07/23/using-query-rules-result-types-and-display-templates-for-a-custom-search-sales-report-in-sharepoint-2013.aspx" target="_blank"&gt;Using Query Rules, Result Types and Display Templates for a Custom Search Sales Report in SharePoint 2013&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;On your enterprise search site, go to Site Settings &amp;ndash;&amp;gt; Master pages and page layouts. Go to the &amp;ldquo;Display Templates&amp;rdquo; folder, then &amp;ldquo;Filters&amp;rdquo;. The easiest way to edit files is to click on the &amp;ldquo;Library&amp;rdquo; tab, then &amp;ldquo;Open with Explorer&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85-metablogapi/4062.image_5F00_3321ABFD.png"&gt;&lt;img style="display: inline;" title="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85-metablogapi/1348.image_5F00_thumb_5F00_4AD8E363.png" alt="image" width="719" height="90" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To create a new display template make a copy of &amp;ldquo;Filter_Default.html&amp;rdquo;, and renamed it to &amp;ldquo;Filter_PieChart.html&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;Prior to editing the file, you can uploaded a couple of dependencies. I&amp;rsquo;ve put jquery-1.7.2.js as well a my own script &amp;ldquo;Filter_PieChart_script.js&amp;rdquo; (attached) into the folder. You also need copy the entire jqplot folder (as a sub folder) into the Filters folder. Download jquery and jqplot from &lt;a href="http://www.jquery.com"&gt;http://www.jquery.com&lt;/a&gt; and &lt;a href="http://www.jqplot.com"&gt;http://www.jqplot.com&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Now, on to editing the file.&lt;/p&gt;
&lt;p&gt;First thing to change is the title tag. The title tag is used in the refiner configuration when chosing the refiner display template you want to use.&amp;nbsp;&lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;title&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;Refinement Item PieChart&lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;title&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;I&amp;rsquo;m leaving all the other properties of the file. Now, on to the interesting part &amp;ndash; how to include other scripts in a display template.&lt;/p&gt;
&lt;p&gt;There is a number of techniques:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use the $includeScript function in a &amp;lt;script&amp;gt;-tag&lt;/li&gt;
&lt;li&gt;Use SharePoint Script On Demand (SP.SOD) in a &amp;lt;script&amp;gt;-tag&lt;/li&gt;
&lt;li&gt;Add the scripts to the master page&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I&amp;rsquo;m using a combination of the two first options. The difference between the two functions is that $includeScript loads the script asynchronously as fast a possible, but there is no guarrantee that the script is loaded. It&amp;rsquo;s suitable for small scripts like my Filter_PieChart_Script.js which is only used&amp;nbsp; to set up jqplot.&lt;/p&gt;
&lt;p&gt;For larger scripts like jquery and jqplot the &lt;a href="http://blogs.msdn.com/b/sharepointdev/archive/2011/01/27/loading-script-in-sharepoint-2010.aspx" target="_blank"&gt;SharePoint Script On Demand&lt;/a&gt; functions are more suitable. With SP.SOD it is possible ensure that a script is loaded before you try to start using it. It is also possible register dependencies between the scripts to make sure scripts are loaded in the correct order.&lt;/p&gt;
&lt;p&gt;The code snippet below is from the modified Filter_PieChart.html where a &amp;lt;script&amp;gt;-tag has been added.&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: #f4f4f4;"&gt;
&lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;body&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;    &lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;script&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;         $includeScript(&lt;span style="color: #0000ff;"&gt;this&lt;/span&gt;.url, &lt;span style="color: #006080;"&gt;"~sitecollection/_catalogs/masterpage/Display Templates/Filters/Filter_PieChart_Script.js"&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;         SP.SOD.registerSod(&lt;span style="color: #006080;"&gt;'jquery-1.7.2.js'&lt;/span&gt;, &lt;span style="color: #0000ff;"&gt;this&lt;/span&gt;.L_Menu_BaseUrl + &lt;span style="color: #006080;"&gt;"/_catalogs/masterpage/Display Templates/Search/jquery-1.7.2.js"&lt;/span&gt;); &lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;         SP.SOD.registerSod(&lt;span style="color: #006080;"&gt;'jquery.jqplot.js'&lt;/span&gt;, &lt;span style="color: #0000ff;"&gt;this&lt;/span&gt;.L_Menu_BaseUrl + &lt;span style="color: #006080;"&gt;"/_catalogs/masterpage/Display Templates/Filters/jqplot/jquery.jqplot.js"&lt;/span&gt;); &lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;         SP.SOD.registerSod(&lt;span style="color: #006080;"&gt;'jqplot.pierenderer.js'&lt;/span&gt;, &lt;span style="color: #0000ff;"&gt;this&lt;/span&gt;.L_Menu_BaseUrl + &lt;span style="color: #006080;"&gt;"/_catalogs/masterpage/Display Templates/Filters/jqplot/plugins/jqplot.pieRenderer.js"&lt;/span&gt;); &lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;         SP.SOD.registerSodDep(&lt;span style="color: #006080;"&gt;'jquery.jqplot.js'&lt;/span&gt;, &lt;span style="color: #006080;"&gt;'jquery-1.7.2.js'&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;         SP.SOD.registerSodDep(&lt;span style="color: #006080;"&gt;'jqplot.pieRenderer.js'&lt;/span&gt;,&lt;span style="color: #006080;"&gt;'jquery.jqplot.js'&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;         $includeCSS(&lt;span style="color: #0000ff;"&gt;this&lt;/span&gt;.url, &lt;span style="color: #006080;"&gt;"~sitecollection/_catalogs/masterpage/Display Templates/Filters/jqplot/jquery.jqplot.css"&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;!--CRLF--&gt;&lt;!--CRLF--&gt;&lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;script&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The custom script Filter_PieChart_Script.js is loaded with $includeScript, in addition to jquery, jqplot and the pierenderer which are loaded in the correct order with SP.SOD.&lt;/p&gt;
&lt;p&gt;The last function used in $includeCSS which can be used to load additional CSS.&lt;/p&gt;
&lt;p&gt;Now, go far down in the file and find&lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;div&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;='Container'&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This is the actual part that displays the normal refiner action links. There is lots of other code in this template. Mostly of it is used to do result site merging of common file types. PPT, PPX, PPS etc are combined into the PowerPoint type.&amp;nbsp; The same for other file types. This part is nice to, so just jump down to the Container-div tag.&lt;/p&gt;
&lt;p&gt;Delete everything inside this tag. I&amp;rsquo;ve modified it look like this:&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: #f4f4f4;"&gt;
&lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;!--CRLF--&gt;&lt;!--CRLF--&gt;&lt;!--CRLF--&gt;&lt;!--CRLF--&gt;&lt;!--CRLF--&gt;&lt;!--CRLF--&gt;&lt;!--CRLF--&gt;&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: #008000;"&gt; var pieChartId = ctx.RefinementControl.containerId + "_pieChart";&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span style="color: #008000;"&gt; var pieHeight = 240 + ((listData.length-1)*20);&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span style="color: #008000;"&gt;_#--&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;        &lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;div&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;='Container'&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            _#= Srch.U.collapsibleRefinerTitle(ctx.RefinementControl.propertyName, ctx.ClientControl.get_id(), refinerCatTitle, iconClass) =#_&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            &lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;div&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="_#= pieChartId =#_"&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;style&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="height: _#= pieHeight =#_px; width: 180px;"&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;div&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        &lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;div&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;        &lt;span style="color: #008000;"&gt;&amp;lt;!--#_&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span style="color: #008000;"&gt; $addRenderContextCallback(ctx, "OnPostRender", function(){&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: #008000;"&gt; SP.SOD.executeFunc("jqplot.pierenderer.js", null, function() {&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span style="color: #008000;"&gt; SetupPieChartFilter(pieChartId, listData) &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: #008000;"&gt; });&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span style="color: #008000;"&gt; }); &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: #008000;"&gt; }&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span style="color: #008000;"&gt; }&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: #008000;"&gt;_#--&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;pre class="csharpcode"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;p&gt;I&amp;rsquo;ve added a couple of variables, pieChartId and pieHeight. The pieChartId will later be used to create a div tag, and also handed to jqplot to tell it where to draw the pieChart. The pieHeight is calculated dynamicly since the legend is under the pie chart the size will vary depending on the number if items in the refiner.&lt;/p&gt;
&lt;p&gt;The only html added is the div-tag with the pieChartId. After the html comes the intresting part. The function $addRenderContextCallback is run after the filter is rendered. We&amp;rsquo;ll run our code inside here, since we then now that everything is rendered. The code uses the SP.SOD.executeFunc to make sure jqplot is loaded. The it calls my custom function SetupPieChartFilter which uses jqplot functions to draw a pie chart based on the listData in the refiner (script attached).&lt;/p&gt;
&lt;p&gt;Once the html is saved SP2013 will generate a Filter_PieChart.js which will be used by the browser. Now the only thing you need to do is to configure the refiner web part to use the new display template:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Edit the page&lt;/li&gt;
&lt;li&gt;Edit the Refinement webpart&lt;/li&gt;
&lt;li&gt;In the Refinement settings, click &amp;ldquo;Choose Refiners&amp;hellip;&amp;rdquo;&lt;/li&gt;
&lt;li&gt;Select the FileType chose your new Display Template &amp;ldquo;Refinement Item PieChart&amp;rdquo;&amp;uml;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85-metablogapi/0272.image_5F00_7C745342.png"&gt;&lt;img style="display: inline;" title="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85-metablogapi/8688.image_5F00_thumb_5F00_65D204FB.png" alt="image" width="244" height="235" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Click OK, Apply etc, and you should be all set!&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85/6204.jqplot_5F00_refiner.zip" target="_blank"&gt;Download the display template&lt;/a&gt; (you still need to download jquery/jqplot)&lt;/p&gt;
&lt;p&gt;&lt;a title="Download the full Visual Studio solution which will deploy a SharePoint feature with the display template" href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85/8306.PieChartRefinerFeature.zip"&gt;Download the full Visual Studio solution which will deploy a SharePoint feature with the display template&lt;/a&gt;&amp;nbsp;(jquery and jqplot are downloaded from cdn.jsdelivr.net)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85/0726.PieChartRefiner.wsp"&gt;WSP file&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10398131" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/murads/archive/tags/search/">search</category><category domain="http://blogs.msdn.com/b/murads/archive/tags/sharepoint+2013/">sharepoint 2013</category><category domain="http://blogs.msdn.com/b/murads/archive/tags/refiner/">refiner</category><category domain="http://blogs.msdn.com/b/murads/archive/tags/jqplot/">jqplot</category><category domain="http://blogs.msdn.com/b/murads/archive/tags/jquery/">jquery</category><category domain="http://blogs.msdn.com/b/murads/archive/tags/display+templates/">display templates</category></item><item><title>Using jQuery UI autocomplete with the REST API to get search results in the search box</title><link>http://blogs.msdn.com/b/murads/archive/2013/02/20/using-jquery-ui-autocomplete-with-the-rest-api-to-get-search-results-in-the-search-box.aspx</link><pubDate>Wed, 20 Feb 2013 08:50:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10395484</guid><dc:creator>Murad Sæter</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/murads/rsscomments.aspx?WeblogPostID=10395484</wfw:commentRss><comments>http://blogs.msdn.com/b/murads/archive/2013/02/20/using-jquery-ui-autocomplete-with-the-rest-api-to-get-search-results-in-the-search-box.aspx#comments</comments><description>&lt;p class="MsoNormal" style="background: white; margin-bottom: 0pt;"&gt;&lt;span lang="EN-US" style="mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us;"&gt;SharePoint 2013 comes with a beautiful REST API that supports both search and suggestions. In this post I’ll show how to easily integrate search results into the search box to quickly show the users the results they want.     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="background: white; margin-bottom: 0pt;"&gt;&lt;span lang="EN-US" style="mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us;"&gt;The example shows normal search results, but it could easily be changed to show e.g. products from a product search demo like &lt;/span&gt;&lt;a href="http://sharepoint.microsoft.com/blog/Pages/BlogPost.aspx?pID=1028"&gt;&lt;span lang="EN-US" style="mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us;"&gt;Contoso Electronics&lt;/span&gt;&lt;/a&gt;&lt;span lang="EN-US" style="mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us;"&gt;.     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="background: white; margin-bottom: 0pt;"&gt;&lt;span lang="EN-US" style="mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us;"&gt;&lt;span style="mso-tab-count: 1;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;      &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="background: white; margin-bottom: 0pt;"&gt;&lt;span lang="EN-US" style="mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us;"&gt;The REST API in SharePoint 2013 can easily be integrated using javascript, as the returns can be returned as JSON.     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="background: white; margin-bottom: 0pt;"&gt;&lt;span lang="EN-US" style="mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us;"&gt;     &lt;p&gt;&amp;#160;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="background: white; margin-bottom: 0pt;"&gt;&lt;span lang="EN-US" style="mso-bidi-font-size: 11.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-ansi-language: en-us;"&gt;I start with a very simple html page, which includes jQuery and jQueryUI from the jquery CDN. &lt;/span&gt;&lt;/p&gt;  &lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);"&gt;   &lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;     &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum1" style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;html&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum2" style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;head&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum3" style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;title&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;REST demo&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;title&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum4" style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;link&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;rel&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&amp;quot;stylesheet&amp;quot;&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;href&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&amp;quot;http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css&amp;quot;&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum5" style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;link&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;rel&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&amp;quot;stylesheet&amp;quot;&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;href&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&amp;quot;http://code.jquery.com/ui/1.10.0/themes/base/jquery.ui.autocomplete.css&amp;quot;&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum6" style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;script&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;src&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&amp;quot;http://code.jquery.com/jquery-1.8.3.js&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;script&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum1" style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt;&amp;#160; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum2" style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt; &amp;lt;script src=&lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;http://code.jquery.com/ui/1.10.0/jquery-ui.js&amp;quot;&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum1" style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &amp;lt;/script&amp;gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum2" style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt; &amp;lt;script type=&lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt; src=&lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;restSearch.js&amp;quot;&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;script&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum7" style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;head&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum8" style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;body&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum9" style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;table&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum10" style="color: rgb(96, 96, 96);"&gt;  10:&lt;/span&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;tbody&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum11" style="color: rgb(96, 96, 96);"&gt;  11:&lt;/span&gt;       &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;tr&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum12" style="color: rgb(96, 96, 96);"&gt;  12:&lt;/span&gt;          &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;td&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;REST Search:&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;td&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum13" style="color: rgb(96, 96, 96);"&gt;  13:&lt;/span&gt;          &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;td&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum14" style="color: rgb(96, 96, 96);"&gt;  14:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;div&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;id&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&amp;quot;menu-container&amp;quot;&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;style&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&amp;quot;width:600px&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum15" style="color: rgb(96, 96, 96);"&gt;  15:&lt;/span&gt;                 &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;input&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;type&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&amp;quot;text&amp;quot;&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;id&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&amp;quot;restSearch&amp;quot;&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;size&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&amp;quot;50&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum16" style="color: rgb(96, 96, 96);"&gt;  16:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum17" style="color: rgb(96, 96, 96);"&gt;  17:&lt;/span&gt;          &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;td&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum18" style="color: rgb(96, 96, 96);"&gt;  18:&lt;/span&gt;      &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;tr&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum19" style="color: rgb(96, 96, 96);"&gt;  19:&lt;/span&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;tbody&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum20" style="color: rgb(96, 96, 96);"&gt;  20:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;table&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum21" style="color: rgb(96, 96, 96);"&gt;  21:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;body&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum22" style="color: rgb(96, 96, 96);"&gt;  22:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;html&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p class="MsoNormal"&gt;&lt;span lang="EN-US" style="mso-ansi-language: en-us;"&gt;
    &lt;p&gt;&amp;#160;&lt;/p&gt;
  &lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span lang="EN-US" style="mso-ansi-language: en-us;"&gt;The input-box with ID restSearch will be referenced later in my script restSearch.js, as well as the div tag with ID menu-container.
    &lt;p&gt;&lt;/p&gt;
  &lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span lang="EN-US" style="mso-ansi-language: en-us;"&gt;The script restSearch.js uses ajax to do a search against the REST API:&lt;/span&gt;&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);"&gt;
  &lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;
    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum1" style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0);"&gt;// Parse an item and create an title/value dictionary with all the properties available&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum2" style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt; getFields(results) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum3" style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt;     r = {};&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum4" style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;for&lt;/span&gt;(&lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; i = 0; i&amp;lt;results.length; i++) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum5" style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(results[i] != undefined &amp;amp;&amp;amp; results[i].Key != undefined) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum6" style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt;             r[results[i].Key] = results[i].Value;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum7" style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum8" style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum9" style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; r;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum10" style="color: rgb(96, 96, 96);"&gt;  10:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum11" style="color: rgb(96, 96, 96);"&gt;  11:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum12" style="color: rgb(96, 96, 96);"&gt;  12:&lt;/span&gt; $(document).ready(&lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;() {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum13" style="color: rgb(96, 96, 96);"&gt;  13:&lt;/span&gt;     &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum14" style="color: rgb(96, 96, 96);"&gt;  14:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; autocomplete = $( &lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;#restSearch&amp;quot;&lt;/span&gt; ).autocomplete({&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum15" style="color: rgb(96, 96, 96);"&gt;  15:&lt;/span&gt;         minLength: 3,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum16" style="color: rgb(96, 96, 96);"&gt;  16:&lt;/span&gt;         source: &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;( request, response ) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum17" style="color: rgb(96, 96, 96);"&gt;  17:&lt;/span&gt;             $.ajax({&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum18" style="color: rgb(96, 96, 96);"&gt;  18:&lt;/span&gt;                 beforeSend: &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt; (request)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum19" style="color: rgb(96, 96, 96);"&gt;  19:&lt;/span&gt;                 {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum20" style="color: rgb(96, 96, 96);"&gt;  20:&lt;/span&gt;                     request.setRequestHeader(&lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;Accept&amp;quot;&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;application/json;odata=verbose;charset=utf-8&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum21" style="color: rgb(96, 96, 96);"&gt;  21:&lt;/span&gt;                 },&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum22" style="color: rgb(96, 96, 96);"&gt;  22:&lt;/span&gt;                 url: &lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;/_api/search/query?querytext='&amp;quot;&lt;/span&gt; + request.term + &lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;*'&amp;quot;&lt;/span&gt;,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum23" style="color: rgb(96, 96, 96);"&gt;  23:&lt;/span&gt;                 dataType: &lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;json&amp;quot;&lt;/span&gt;,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum24" style="color: rgb(96, 96, 96);"&gt;  24:&lt;/span&gt;                 success: &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;( data ) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum25" style="color: rgb(96, 96, 96);"&gt;  25:&lt;/span&gt;                     response( $.map( data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results, &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;( item ) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum26" style="color: rgb(96, 96, 96);"&gt;  26:&lt;/span&gt;                         &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum27" style="color: rgb(96, 96, 96);"&gt;  27:&lt;/span&gt;                             fields: getFields(item.Cells.results)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum28" style="color: rgb(96, 96, 96);"&gt;  28:&lt;/span&gt;                         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum29" style="color: rgb(96, 96, 96);"&gt;  29:&lt;/span&gt;                     }));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum30" style="color: rgb(96, 96, 96);"&gt;  30:&lt;/span&gt;                 },&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum31" style="color: rgb(96, 96, 96);"&gt;  31:&lt;/span&gt;                 error: &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;( data ) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum32" style="color: rgb(96, 96, 96);"&gt;  32:&lt;/span&gt;                     alert(&lt;span style="color: rgb(0, 96, 128);"&gt;'search error'&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum33" style="color: rgb(96, 96, 96);"&gt;  33:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum34" style="color: rgb(96, 96, 96);"&gt;  34:&lt;/span&gt;             });&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum35" style="color: rgb(96, 96, 96);"&gt;  35:&lt;/span&gt;         },&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum36" style="color: rgb(96, 96, 96);"&gt;  36:&lt;/span&gt;         &lt;span style="color: rgb(0, 128, 0);"&gt;// Run this when the item is in focused (not selected)&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum37" style="color: rgb(96, 96, 96);"&gt;  37:&lt;/span&gt;         focus: &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;( &lt;span style="color: rgb(0, 0, 255);"&gt;event&lt;/span&gt;, ui ) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum38" style="color: rgb(96, 96, 96);"&gt;  38:&lt;/span&gt;             &lt;span style="color: rgb(0, 128, 0);"&gt;//$( &amp;quot;#restSearch&amp;quot; ).val(ui.item.value );&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum39" style="color: rgb(96, 96, 96);"&gt;  39:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum40" style="color: rgb(96, 96, 96);"&gt;  40:&lt;/span&gt;         },&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum41" style="color: rgb(96, 96, 96);"&gt;  41:&lt;/span&gt;         &lt;span style="color: rgb(0, 128, 0);"&gt;// Run this when the item is selected&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum42" style="color: rgb(96, 96, 96);"&gt;  42:&lt;/span&gt;         select: &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;( &lt;span style="color: rgb(0, 0, 255);"&gt;event&lt;/span&gt;, ui ) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum43" style="color: rgb(96, 96, 96);"&gt;  43:&lt;/span&gt;             location.href = ui.item.fields.Path;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum44" style="color: rgb(96, 96, 96);"&gt;  44:&lt;/span&gt;         },&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum45" style="color: rgb(96, 96, 96);"&gt;  45:&lt;/span&gt;         appendTo: $(&lt;span style="color: rgb(0, 96, 128);"&gt;'#menu-container'&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum46" style="color: rgb(96, 96, 96);"&gt;  46:&lt;/span&gt;     }).data( &lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;uiAutocomplete&amp;quot;&lt;/span&gt; )._renderItem = &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;( ul, item ) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum47" style="color: rgb(96, 96, 96);"&gt;  47:&lt;/span&gt;         &lt;span style="color: rgb(0, 128, 0);"&gt;// format the documents using the OOTB SharePoint icons&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum48" style="color: rgb(96, 96, 96);"&gt;  48:&lt;/span&gt;         img = &lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;ic&amp;quot;&lt;/span&gt; + item.fields.FileType + &lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;.png&amp;quot;&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum49" style="color: rgb(96, 96, 96);"&gt;  49:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(item.fields.FileType == &lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;html&amp;quot;&lt;/span&gt;) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum50" style="color: rgb(96, 96, 96);"&gt;  50:&lt;/span&gt;             img = &lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;html16.png&amp;quot;&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum51" style="color: rgb(96, 96, 96);"&gt;  51:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum52" style="color: rgb(96, 96, 96);"&gt;  52:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; $(&lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;&amp;lt;li&amp;gt;&amp;quot;&lt;/span&gt;).append(&lt;span style="color: rgb(0, 96, 128);"&gt;'&amp;lt;a&amp;gt;&amp;lt;img style=&amp;quot;margin-right:3px;top:3px;&amp;quot; src=&amp;quot;/_layouts/15/images/'&lt;/span&gt;+ img +&lt;span style="color: rgb(0, 96, 128);"&gt;'&amp;quot;&amp;gt;'&lt;/span&gt; + item.fields.Title + &lt;span style="color: rgb(0, 96, 128);"&gt;'&amp;lt;/a&amp;gt;'&lt;/span&gt; )&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum53" style="color: rgb(96, 96, 96);"&gt;  53:&lt;/span&gt;             .appendTo( ul );&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum54" style="color: rgb(96, 96, 96);"&gt;  54:&lt;/span&gt;     };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum55" style="color: rgb(96, 96, 96);"&gt;  55:&lt;/span&gt; });&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p class="MsoNormal"&gt;&amp;#160;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span lang="EN-US" style="mso-ansi-language: en-us;"&gt;This is more or less out of the box jQueryUI-autocomplete magic.&amp;#160; The first function &lt;/span&gt;&lt;span lang="EN-US" style="background: rgb(242, 244, 255); color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-ansi-language: en-us;"&gt;getFields&lt;/span&gt;&lt;span lang="EN-US" style="mso-ansi-language: en-us;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;#160; &lt;/span&gt;parses the JSON result item in to a key/value dictionary which makes all the managed properties easily available. The $.ajax function executes the query against the REST API and gets a result set in JSON back.There is a select function that will redirect the user direct to the result when selecting a hit. At the end there is some custom formatting of the autocomplete entries to show the document format icon in the list.

    &lt;p&gt;&lt;/p&gt;
  &lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span lang="EN-US" style="mso-ansi-language: en-us;"&gt;It ends up looking like this:
    &lt;p&gt;&lt;/p&gt;
  &lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof: yes;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85-metablogapi/1778.clip_5F00_image002_5F00_29F38DF6.jpg"&gt;&lt;img title="clip_image002" style="display: inline;" border="0" alt="clip_image002" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85-metablogapi/3021.clip_5F00_image002_5F00_thumb_5F00_485DCEDF.jpg" width="473" height="256" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;span lang="EN-US" style="mso-ansi-language: en-us;"&gt;
    &lt;p&gt;&lt;/p&gt;
  &lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span lang="EN-US" style="mso-ansi-language: en-us;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85/5657.restSearch.zip"&gt;I’veattached the script file&lt;/a&gt;, just put them somewhere on your SharePoint and it will work fine.&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span lang="EN-US" style="mso-ansi-language: en-us;"&gt;
    &lt;p&gt;&amp;#160;&lt;/p&gt;
  &lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10395484" width="1" height="1"&gt;</description></item><item><title>Building PDF search preview in SharePoint 2013</title><link>http://blogs.msdn.com/b/murads/archive/2012/11/02/building-a-pdf-search-preview-in-sharepoint-2013.aspx</link><pubDate>Fri, 02 Nov 2012 13:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10365229</guid><dc:creator>Murad Sæter</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/murads/rsscomments.aspx?WeblogPostID=10365229</wfw:commentRss><comments>http://blogs.msdn.com/b/murads/archive/2012/11/02/building-a-pdf-search-preview-in-sharepoint-2013.aspx#comments</comments><description>&lt;p&gt;The new Office Web Apps 2013 integrates very nicely with SharePoint 2013, both when viewing/editing office content as well as with the search preview of the documents. One very common format that is not supported is PDF, and in this article I will build my own WOPI App that supports PDFs by using &lt;a href="http://www.mattephraim.com/blog/2009/01/06/a-simple-c-wrapper-for-ghostscript/" target="_blank"&gt;a simple C# Wrapper for Ghostscript&lt;/a&gt; written by &lt;a href="http://www.mattephraim.com/" target="_blank"&gt;Matthew Ephraim&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I read &lt;a href="http://www.wictorwilen.se/" target="_blank"&gt;Wictor Wil&amp;eacute;n&lt;/a&gt;&amp;rsquo;s blog series about &lt;a href="http://www.wictorwilen.se/sharepoint-2013-building-your-own-wopi-client-part-1" target="_blank"&gt;Building your own WOPI Client&lt;/a&gt; and I got really inspired. It is highly recommended that you read Wictor&amp;rsquo;s blog series prior to continuing with the PDF previewer, since I will re-use most of the code from Wictor&amp;rsquo;s blog.&lt;/p&gt;
&lt;p&gt;The discovery.xml, which describes the WOPI App (client) should hosted on /hosting/discovery in your APP, looks like this:&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: #f4f4f4;"&gt;
&lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum1" style="color: #606060;"&gt; 1:&lt;/span&gt; &amp;lt;?xml version=&lt;span style="color: #006080;"&gt;"1.0"&lt;/span&gt; encoding=&lt;span style="color: #006080;"&gt;"utf-8"&lt;/span&gt;?&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum2" style="color: #606060;"&gt; 2:&lt;/span&gt; &amp;lt;wopi-discovery&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum3" style="color: #606060;"&gt; 3:&lt;/span&gt;   &amp;lt;net-zone name=&lt;span style="color: #006080;"&gt;"internal-http"&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum4" style="color: #606060;"&gt; 4:&lt;/span&gt;     &amp;lt;app name=&lt;span style="color: #006080;"&gt;"GhostscriptPDF"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum5" style="color: #606060;"&gt; 5:&lt;/span&gt;          favIconUrl=&lt;span style="color: #006080;"&gt;"http://spmurads:8888/images/pdf.ico"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum6" style="color: #606060;"&gt; 6:&lt;/span&gt;          checkLicense=&lt;span style="color: #006080;"&gt;"false"&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum7" style="color: #606060;"&gt; 7:&lt;/span&gt;       &amp;lt;action name=&lt;span style="color: #006080;"&gt;"view"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum8" style="color: #606060;"&gt; 8:&lt;/span&gt;               ext=&lt;span style="color: #006080;"&gt;"pdf"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum9" style="color: #606060;"&gt; 9:&lt;/span&gt;               &lt;span style="color: #0000ff;"&gt;default&lt;/span&gt;=&lt;span style="color: #006080;"&gt;"true"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum10" style="color: #606060;"&gt; 10:&lt;/span&gt;               urlsrc=&lt;span style="color: #006080;"&gt;"http://spmurads:8888/viewer.aspx?&amp;amp;lt;theme=THEME_ID&amp;amp;amp;&amp;amp;gt;"&lt;/span&gt; /&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum11" style="color: #606060;"&gt; 11:&lt;/span&gt;       &amp;lt;action name=&lt;span style="color: #006080;"&gt;"interactivepreview"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum12" style="color: #606060;"&gt; 12:&lt;/span&gt;         ext=&lt;span style="color: #006080;"&gt;"pdf"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum13" style="color: #606060;"&gt; 13:&lt;/span&gt;         &lt;span style="color: #0000ff;"&gt;default&lt;/span&gt;=&lt;span style="color: #006080;"&gt;"false"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum14" style="color: #606060;"&gt; 14:&lt;/span&gt;         urlsrc=&lt;span style="color: #006080;"&gt;"http://spmurads:8888/viewer.aspx?&amp;amp;lt;ui=UI_LLCC&amp;amp;amp;&amp;amp;gt;&amp;amp;lt;rs=DC_LLCC&amp;amp;amp;&amp;amp;gt;&amp;amp;amp;previewmode=true"&lt;/span&gt; /&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum15" style="color: #606060;"&gt; 15:&lt;/span&gt;     &amp;lt;/app&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum16" style="color: #606060;"&gt; 16:&lt;/span&gt;   &amp;lt;/net-zone&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum17" style="color: #606060;"&gt; 17:&lt;/span&gt;   &amp;lt;proof-key oldvalue=&lt;span style="color: #006080;"&gt;""&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;value&lt;/span&gt;=&lt;span style="color: #006080;"&gt;"BgIAAA&amp;hellip;."&lt;/span&gt; /&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;p&gt;&lt;span id="lnum18" style="color: #606060;"&gt;18:&lt;/span&gt; &amp;lt;/wopi-discovery&amp;gt;&lt;/p&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Note that the proof-key has been removed, so you need to generate your own. See Wictor&amp;rsquo;s article for the details there. My web app is hosted on my server called &lt;a href="http://spmurads:8888"&gt;http://spmurads:8888&lt;/a&gt; (yes it works on other ports than 80), which I just created on my SharePoint server.&lt;/p&gt;
&lt;p&gt;Once &lt;a href="http://spmurads:8888/hosting/discovery"&gt;http://spmurads:8888/hosting/discovery&lt;/a&gt; return the discovery.xml above, the add WOPI App can be added to my SharePoint server using powershell:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;New-SPWOPIBinding -ServerName spmurads:8888 &amp;ndash;AllowHTTP&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;To host discovery.xml on /hosting/discovery you need to add discovery.xml as a defaultDocument in your web.config:&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: #f4f4f4;"&gt;
&lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum1" style="color: #606060;"&gt; 1:&lt;/span&gt; &amp;lt;configuration&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum2" style="color: #606060;"&gt; 2:&lt;/span&gt;     &amp;lt;system.web&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum3" style="color: #606060;"&gt; 3:&lt;/span&gt;       &amp;lt;compilation debug=&lt;span style="color: #006080;"&gt;"true"&lt;/span&gt; targetFramework=&lt;span style="color: #006080;"&gt;"4.5"&lt;/span&gt; /&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum4" style="color: #606060;"&gt; 4:&lt;/span&gt;       &amp;lt;httpRuntime targetFramework=&lt;span style="color: #006080;"&gt;"4.5"&lt;/span&gt; /&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum5" style="color: #606060;"&gt; 5:&lt;/span&gt;       &amp;lt;customErrors mode=&lt;span style="color: #006080;"&gt;"Off"&lt;/span&gt;/&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum6" style="color: #606060;"&gt; 6:&lt;/span&gt;     &amp;lt;/system.web&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum7" style="color: #606060;"&gt; 7:&lt;/span&gt;     &amp;lt;system.webServer&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum8" style="color: #606060;"&gt; 8:&lt;/span&gt;     &amp;lt;defaultDocument enabled=&lt;span style="color: #006080;"&gt;"true"&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum9" style="color: #606060;"&gt; 9:&lt;/span&gt;       &amp;lt;files&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum10" style="color: #606060;"&gt; 10:&lt;/span&gt;         &amp;lt;add &lt;span style="color: #0000ff;"&gt;value&lt;/span&gt;=&lt;span style="color: #006080;"&gt;"discovery.xml"&lt;/span&gt;/&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum11" style="color: #606060;"&gt; 11:&lt;/span&gt;       &amp;lt;/files&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum12" style="color: #606060;"&gt; 12:&lt;/span&gt;     &amp;lt;/defaultDocument&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum13" style="color: #606060;"&gt; 13:&lt;/span&gt;   &amp;lt;/system.webServer&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum14" style="color: #606060;"&gt; 14:&lt;/span&gt;   &amp;lt;location path=&lt;span style="color: #006080;"&gt;"hosting/discovery"&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum15" style="color: #606060;"&gt; 15:&lt;/span&gt;     &amp;lt;system.web&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum16" style="color: #606060;"&gt; 16:&lt;/span&gt;       &amp;lt;authorization&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum17" style="color: #606060;"&gt; 17:&lt;/span&gt;         &amp;lt;allow users =&lt;span style="color: #006080;"&gt;"*"&lt;/span&gt; /&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum18" style="color: #606060;"&gt; 18:&lt;/span&gt;       &amp;lt;/authorization&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum19" style="color: #606060;"&gt; 19:&lt;/span&gt;     &amp;lt;/system.web&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum20" style="color: #606060;"&gt; 20:&lt;/span&gt;   &amp;lt;/location&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum21" style="color: #606060;"&gt; 21:&lt;/span&gt;   &amp;lt;location path=&lt;span style="color: #006080;"&gt;"hosting/discovery/discovery.xml"&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum22" style="color: #606060;"&gt; 22:&lt;/span&gt;     &amp;lt;system.web&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum23" style="color: #606060;"&gt; 23:&lt;/span&gt;       &amp;lt;authorization&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum24" style="color: #606060;"&gt; 24:&lt;/span&gt;         &amp;lt;allow users =&lt;span style="color: #006080;"&gt;"*"&lt;/span&gt; /&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum25" style="color: #606060;"&gt; 25:&lt;/span&gt;       &amp;lt;/authorization&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum26" style="color: #606060;"&gt; 26:&lt;/span&gt;     &amp;lt;/system.web&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum27" style="color: #606060;"&gt; 27:&lt;/span&gt;   &amp;lt;/location&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum28" style="color: #606060;"&gt; 28:&lt;/span&gt; &amp;lt;/configuration&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;I&amp;rsquo;ve also made sure the document is available for anonymous users.&lt;/p&gt;
&lt;p&gt;Now to the viewer code. There is lots of magic around getting the file from the WOPI Server (SharePoint). This is explained very well in Wictor&amp;rsquo;s blog series, so it will not be repeated here. However I found that an additional step (in part 2) needs to be done to get it to work with the RTM version of SharePoint.&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: #f4f4f4;"&gt;
&lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum1" style="color: #606060;"&gt; 1:&lt;/span&gt; $config = (Get-SPSecurityTokenServiceConfig)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum2" style="color: #606060;"&gt; 2:&lt;/span&gt; $config.AllowOAuthOverHttp = $&lt;span style="color: #0000ff;"&gt;true&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum3" style="color: #606060;"&gt; 3:&lt;/span&gt; $config.Update()&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;I have modified Wictor&amp;rsquo;s viewer.aspx.cs to run GhostScript&amp;nbsp; and create jpg previews and show the images to the user. It does some simple caching of the generated files, as well giving read access to the current user. The image files are written to the local \inetpub directory (my server on port 8888) which then easily can be shown to the user.&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.58%; height: 311px; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: #f4f4f4;"&gt;
&lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum1" style="color: #606060;"&gt; 1:&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;namespace&lt;/span&gt; Microsoft.GhostWOPI&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum2" style="color: #606060;"&gt; 2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum3" style="color: #606060;"&gt; 3:&lt;/span&gt;     &lt;span style="color: #0000ff;"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;partial&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;class&lt;/span&gt; viewer : System.Web.UI.Page&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum4" style="color: #606060;"&gt; 4:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum5" style="color: #606060;"&gt; 5:&lt;/span&gt;         &lt;span style="color: #0000ff;"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;string&lt;/span&gt; images = &lt;span style="color: #006080;"&gt;""&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum6" style="color: #606060;"&gt; 6:&lt;/span&gt;         &lt;span style="color: #0000ff;"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;string&lt;/span&gt; metadata = &lt;span style="color: #006080;"&gt;""&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum7" style="color: #606060;"&gt; 7:&lt;/span&gt;         &lt;span style="color: #0000ff;"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;string&lt;/span&gt; origdoc = &lt;span style="color: #006080;"&gt;""&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum8" style="color: #606060;"&gt; 8:&lt;/span&gt;         &lt;span style="color: #0000ff;"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;bool&lt;/span&gt; previewMode = &lt;span style="color: #0000ff;"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum9" style="color: #606060;"&gt; 9:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum10" style="color: #606060;"&gt; 10:&lt;/span&gt;         &lt;span style="color: #0000ff;"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;void&lt;/span&gt; Page_Load(&lt;span style="color: #0000ff;"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum11" style="color: #606060;"&gt; 11:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum12" style="color: #606060;"&gt; 12:&lt;/span&gt;             &lt;span style="color: #0000ff;"&gt;string&lt;/span&gt; src = Request.QueryString[&lt;span style="color: #006080;"&gt;"WOPISrc"&lt;/span&gt;];&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum13" style="color: #606060;"&gt; 13:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum14" style="color: #606060;"&gt; 14:&lt;/span&gt;             &lt;span style="color: #008000;"&gt;// Used in preview mode (search result)&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum15" style="color: #606060;"&gt; 15:&lt;/span&gt;             &lt;span style="color: #0000ff;"&gt;string&lt;/span&gt; preview = Request.QueryString[&lt;span style="color: #006080;"&gt;"previewmode"&lt;/span&gt;];&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum16" style="color: #606060;"&gt; 16:&lt;/span&gt;             &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum17" style="color: #606060;"&gt; 17:&lt;/span&gt;             previewMode = !String.IsNullOrEmpty(preview);&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum18" style="color: #606060;"&gt; 18:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum19" style="color: #606060;"&gt; 19:&lt;/span&gt;             &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; (!String.IsNullOrEmpty(src))&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum20" style="color: #606060;"&gt; 20:&lt;/span&gt;             {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum21" style="color: #606060;"&gt; 21:&lt;/span&gt;                 &lt;span style="color: #0000ff;"&gt;string&lt;/span&gt; access_token = Request.Form[&lt;span style="color: #006080;"&gt;"access_token"&lt;/span&gt;];&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum22" style="color: #606060;"&gt; 22:&lt;/span&gt;                 &lt;span style="color: #0000ff;"&gt;string&lt;/span&gt; access_token_ttl = Request.Form[&lt;span style="color: #006080;"&gt;"access_token_ttl"&lt;/span&gt;];&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum23" style="color: #606060;"&gt; 23:&lt;/span&gt;                &lt;span style="color: #008000;"&gt;// Get the metadata&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum24" style="color: #606060;"&gt; 24:&lt;/span&gt;                 &lt;span style="color: #0000ff;"&gt;string&lt;/span&gt; url = String.Format(&lt;span style="color: #006080;"&gt;"{0}"&lt;/span&gt;, src);&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum25" style="color: #606060;"&gt; 25:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum26" style="color: #606060;"&gt; 26:&lt;/span&gt;                 &lt;span style="color: #0000ff;"&gt;string&lt;/span&gt; meta = &lt;span style="color: #006080;"&gt;""&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum27" style="color: #606060;"&gt; 27:&lt;/span&gt;                 &lt;span style="color: #0000ff;"&gt;using&lt;/span&gt; (WOPIWebClient client =&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum28" style="color: #606060;"&gt; 28:&lt;/span&gt;                      &lt;span style="color: #0000ff;"&gt;new&lt;/span&gt; WOPIWebClient(url, access_token, access_token_ttl))&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum29" style="color: #606060;"&gt; 29:&lt;/span&gt;                 {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum30" style="color: #606060;"&gt; 30:&lt;/span&gt;                     meta = client.DownloadString(url);&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum31" style="color: #606060;"&gt; 31:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum32" style="color: #606060;"&gt; 32:&lt;/span&gt;                 JsonTextReader jr = &lt;span style="color: #0000ff;"&gt;new&lt;/span&gt; JsonTextReader(&lt;span style="color: #0000ff;"&gt;new&lt;/span&gt; StringReader(meta));&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum33" style="color: #606060;"&gt; 33:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum34" style="color: #606060;"&gt; 34:&lt;/span&gt;                 &lt;span style="color: #008000;"&gt;// Parse meta data&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum35" style="color: #606060;"&gt; 35:&lt;/span&gt;                 &lt;span style="color: #0000ff;"&gt;string&lt;/span&gt; version = &lt;span style="color: #006080;"&gt;""&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum36" style="color: #606060;"&gt; 36:&lt;/span&gt;                 &lt;span style="color: #0000ff;"&gt;string&lt;/span&gt; propertyName = &lt;span style="color: #006080;"&gt;""&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum37" style="color: #606060;"&gt; 37:&lt;/span&gt;                 &lt;span style="color: #0000ff;"&gt;string&lt;/span&gt; userId = &lt;span style="color: #006080;"&gt;""&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum38" style="color: #606060;"&gt; 38:&lt;/span&gt;                 &lt;span style="color: #0000ff;"&gt;while&lt;/span&gt; (jr.Read())&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum39" style="color: #606060;"&gt; 39:&lt;/span&gt;                 {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum40" style="color: #606060;"&gt; 40:&lt;/span&gt;                     &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; (jr.TokenType.ToString().Equals(&lt;span style="color: #006080;"&gt;"PropertyName"&lt;/span&gt;))&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum41" style="color: #606060;"&gt; 41:&lt;/span&gt;                         propertyName = (&lt;span style="color: #0000ff;"&gt;string&lt;/span&gt;)jr.Value;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum42" style="color: #606060;"&gt; 42:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum43" style="color: #606060;"&gt; 43:&lt;/span&gt;                     &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; (jr.TokenType.ToString().Equals(&lt;span style="color: #006080;"&gt;"String"&lt;/span&gt;))&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum44" style="color: #606060;"&gt; 44:&lt;/span&gt;                     {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum45" style="color: #606060;"&gt; 45:&lt;/span&gt;                         &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; (propertyName.Equals(&lt;span style="color: #006080;"&gt;"Version"&lt;/span&gt;))&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum46" style="color: #606060;"&gt; 46:&lt;/span&gt;                         {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum47" style="color: #606060;"&gt; 47:&lt;/span&gt;                             version = HttpUtility.UrlDecode(jr.Value.ToString());&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum48" style="color: #606060;"&gt; 48:&lt;/span&gt;                         }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum49" style="color: #606060;"&gt; 49:&lt;/span&gt;                         &lt;span style="color: #0000ff;"&gt;else&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; (propertyName.Equals(&lt;span style="color: #006080;"&gt;"UserId"&lt;/span&gt;))&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum50" style="color: #606060;"&gt; 50:&lt;/span&gt;                         {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum51" style="color: #606060;"&gt; 51:&lt;/span&gt;                             userId = jr.Value.ToString();&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum52" style="color: #606060;"&gt; 52:&lt;/span&gt;                         }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum53" style="color: #606060;"&gt; 53:&lt;/span&gt;                         &lt;span style="color: #0000ff;"&gt;else&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; (propertyName.Equals(&lt;span style="color: #006080;"&gt;"ClientUrl"&lt;/span&gt;))&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum54" style="color: #606060;"&gt; 54:&lt;/span&gt;                         {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum55" style="color: #606060;"&gt; 55:&lt;/span&gt;                             origdoc = jr.Value.ToString();&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum56" style="color: #606060;"&gt; 56:&lt;/span&gt;                         }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum57" style="color: #606060;"&gt; 57:&lt;/span&gt;                     }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum58" style="color: #606060;"&gt; 58:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum59" style="color: #606060;"&gt; 59:&lt;/span&gt;                 &lt;span style="color: #008000;"&gt;// Get the DOMAIN\user&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum60" style="color: #606060;"&gt; 60:&lt;/span&gt;                 userId = userId.Split(&lt;span style="color: #006080;"&gt;'|'&lt;/span&gt;)[1];&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum61" style="color: #606060;"&gt; 61:&lt;/span&gt;                 &lt;span style="color: #008000;"&gt;// Get the content&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum62" style="color: #606060;"&gt; 62:&lt;/span&gt;                 url = String.Format(&lt;span style="color: #006080;"&gt;"{0}/contents"&lt;/span&gt;, src);&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum63" style="color: #606060;"&gt; 63:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum64" style="color: #606060;"&gt; 64:&lt;/span&gt;                 &lt;span style="color: #008000;"&gt;// create a unique filename &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum65" style="color: #606060;"&gt; 65:&lt;/span&gt;                 &lt;span style="color: #0000ff;"&gt;string&lt;/span&gt; fileName = version;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum66" style="color: #606060;"&gt; 66:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum67" style="color: #606060;"&gt; 67:&lt;/span&gt;                 &lt;span style="color: #008000;"&gt;// create filenames based with only legal characters&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum68" style="color: #606060;"&gt; 68:&lt;/span&gt;                 &lt;span style="color: #0000ff;"&gt;string&lt;/span&gt; dirName = src.Replace(&lt;span style="color: #006080;"&gt;"http://"&lt;/span&gt;, &lt;span style="color: #006080;"&gt;""&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum69" style="color: #606060;"&gt; 69:&lt;/span&gt;                 fileName = fileName.Replace(&lt;span style="color: #006080;"&gt;"\\", "&lt;/span&gt;_&lt;span style="color: #006080;"&gt;").Replace("&lt;/span&gt;/&lt;span style="color: #006080;"&gt;", "&lt;/span&gt;_&lt;span style="color: #006080;"&gt;").Replace("&lt;/span&gt;:&lt;span style="color: #006080;"&gt;", "&lt;/span&gt;_&lt;span style="color: #006080;"&gt;").Replace("&lt;/span&gt;.&lt;span style="color: #006080;"&gt;", "&lt;/span&gt;_&lt;span style="color: #006080;"&gt;").Replace("&lt;/span&gt;&amp;amp;&lt;span style="color: #006080;"&gt;", "&lt;/span&gt;_&lt;span style="color: #006080;"&gt;").Replace("&lt;/span&gt;{&lt;span style="color: #006080;"&gt;", "&lt;/span&gt;_&lt;span style="color: #006080;"&gt;").Replace("&lt;/span&gt;}&lt;span style="color: #006080;"&gt;", "&lt;/span&gt;_&lt;span style="color: #006080;"&gt;").Replace("&lt;/span&gt;\&lt;span style="color: #006080;"&gt;""&lt;/span&gt;, &lt;span style="color: #006080;"&gt;"_"&lt;/span&gt;).Replace(&lt;span style="color: #006080;"&gt;","&lt;/span&gt;, &lt;span style="color: #006080;"&gt;"_"&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum70" style="color: #606060;"&gt; 70:&lt;/span&gt;                 dirName = dirName.Replace(&lt;span style="color: #006080;"&gt;"\\", "&lt;/span&gt;_&lt;span style="color: #006080;"&gt;").Replace("&lt;/span&gt;/&lt;span style="color: #006080;"&gt;", "&lt;/span&gt;_&lt;span style="color: #006080;"&gt;").Replace("&lt;/span&gt;:&lt;span style="color: #006080;"&gt;", "&lt;/span&gt;_&lt;span style="color: #006080;"&gt;").Replace("&lt;/span&gt;.&lt;span style="color: #006080;"&gt;", "&lt;/span&gt;_&lt;span style="color: #006080;"&gt;").Replace("&lt;/span&gt;&amp;amp;&lt;span style="color: #006080;"&gt;", "&lt;/span&gt;_&lt;span style="color: #006080;"&gt;").Replace("&lt;/span&gt;{&lt;span style="color: #006080;"&gt;", "&lt;/span&gt;_&lt;span style="color: #006080;"&gt;").Replace("&lt;/span&gt;}&lt;span style="color: #006080;"&gt;", "&lt;/span&gt;_&lt;span style="color: #006080;"&gt;").Replace("&lt;/span&gt;\&lt;span style="color: #006080;"&gt;""&lt;/span&gt;, &lt;span style="color: #006080;"&gt;"_"&lt;/span&gt;).Replace(&lt;span style="color: #006080;"&gt;","&lt;/span&gt;, &lt;span style="color: #006080;"&gt;"_"&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum71" style="color: #606060;"&gt; 71:&lt;/span&gt;                 &lt;span style="color: #0000ff;"&gt;string&lt;/span&gt; cacheDir = &lt;span style="color: #006080;"&gt;"C:\\inetpub\\ghostwopi\\cache\\" + dirName + "&lt;/span&gt;\\&lt;span style="color: #006080;"&gt;";&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum72" style="color: #606060;"&gt; 72:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum73" style="color: #606060;"&gt; 73:&lt;/span&gt;                 // create directory&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum74" style="color: #606060;"&gt; 74:&lt;/span&gt;                 if (!System.IO.Directory.Exists(cacheDir))&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum75" style="color: #606060;"&gt; 75:&lt;/span&gt;                 {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum76" style="color: #606060;"&gt; 76:&lt;/span&gt;                     System.IO.Directory.CreateDirectory(cacheDir);&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum77" style="color: #606060;"&gt; 77:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum78" style="color: #606060;"&gt; 78:&lt;/span&gt;                 // make sure the user has read access&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum79" style="color: #606060;"&gt; 79:&lt;/span&gt;                 AddFileSecurity(cacheDir, userId, FileSystemRights.Read, AccessControlType.Allow);&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum80" style="color: #606060;"&gt; 80:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum81" style="color: #606060;"&gt; 81:&lt;/span&gt;                 string pdfName = cacheDir + fileName + ".pdf&lt;span style="color: #006080;"&gt;";&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum82" style="color: #606060;"&gt; 82:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum83" style="color: #606060;"&gt; 83:&lt;/span&gt;                 // Download the PDF from SharePoint and cache it locally&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum84" style="color: #606060;"&gt; 84:&lt;/span&gt;                 if(!File.Exists(pdfName)) {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum85" style="color: #606060;"&gt; 85:&lt;/span&gt;                     using (WOPIWebClient client =&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum86" style="color: #606060;"&gt; 86:&lt;/span&gt;                         new WOPIWebClient(url, access_token, access_token_ttl))&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum87" style="color: #606060;"&gt; 87:&lt;/span&gt;                     {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum88" style="color: #606060;"&gt; 88:&lt;/span&gt;                         byte[] data = client.DownloadData(url);&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum89" style="color: #606060;"&gt; 89:&lt;/span&gt;                         File.WriteAllBytes(pdfName, data);&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum90" style="color: #606060;"&gt; 90:&lt;/span&gt;                     }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum91" style="color: #606060;"&gt; 91:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum92" style="color: #606060;"&gt; 92:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum93" style="color: #606060;"&gt; 93:&lt;/span&gt;                 // Call GhostScript to generate jpg previews&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum94" style="color: #606060;"&gt; 94:&lt;/span&gt;                 if(!File.Exists(cacheDir + fileName + ".001.jpg&lt;span style="color: #006080;"&gt;")) {&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum95" style="color: #606060;"&gt; 95:&lt;/span&gt;                     GhostscriptWrapper.GeneratePageThumbs(pdfName, cacheDir + fileName + ".%03d.jpg&lt;span style="color: #006080;"&gt;", 1, 300, 100, 100);&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum96" style="color: #606060;"&gt; 96:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum97" style="color: #606060;"&gt; 97:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum98" style="color: #606060;"&gt; 98:&lt;/span&gt;                 FileInfo[] files = (new DirectoryInfo(cacheDir)).GetFiles("*.jpg&lt;span style="color: #006080;"&gt;");&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum99" style="color: #606060;"&gt; 99:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum100" style="color: #606060;"&gt; 100:&lt;/span&gt;                 // Create simple HTML&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum101" style="color: #606060;"&gt; 101:&lt;/span&gt;                 for(int i=0;i&amp;lt;files.Length; i++) {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum102" style="color: #606060;"&gt; 102:&lt;/span&gt;                     // make sure the user has read access&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum103" style="color: #606060;"&gt; 103:&lt;/span&gt;                     AddFileSecurity(files[i].FullName, userId, FileSystemRights.Read, AccessControlType.Allow);&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum104" style="color: #606060;"&gt; 104:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum105" style="color: #606060;"&gt; 105:&lt;/span&gt;                     if (!previewMode)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum106" style="color: #606060;"&gt; 106:&lt;/span&gt;                     {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum107" style="color: #606060;"&gt; 107:&lt;/span&gt;                         images += "&amp;lt;img border=\&lt;span style="color: #006080;"&gt;"1\" src=\"http://spmurads:8888/cache/"&lt;/span&gt; + dirName + &lt;span style="color: #006080;"&gt;"/"&lt;/span&gt; + files[i].Name + &lt;span style="color: #006080;"&gt;"\"&amp;gt;&amp;lt;hr&amp;gt;\n"&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum108" style="color: #606060;"&gt; 108:&lt;/span&gt;                     }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum109" style="color: #606060;"&gt; 109:&lt;/span&gt;                     &lt;span style="color: #0000ff;"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum110" style="color: #606060;"&gt; 110:&lt;/span&gt;                     {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum111" style="color: #606060;"&gt; 111:&lt;/span&gt;                         images += &lt;span style="color: #006080;"&gt;"&amp;lt;img border=\"1\" width=\"510\" src=\"http://spmurads:8888/cache/"&lt;/span&gt; + dirName + &lt;span style="color: #006080;"&gt;"/"&lt;/span&gt; + files[i].Name + &lt;span style="color: #006080;"&gt;"\"&amp;gt;&amp;lt;hr&amp;gt;\n"&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum112" style="color: #606060;"&gt; 112:&lt;/span&gt;                     }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum113" style="color: #606060;"&gt; 113:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum114" style="color: #606060;"&gt; 114:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum115" style="color: #606060;"&gt; 115:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;There are references to WOPIWebClient which you can get from Wictor&amp;rsquo;s blog, &lt;a href="http://www.mattephraim.com/blog/2009/01/06/a-simple-c-wrapper-for-ghostscript/" target="_blank"&gt;Ghostscript wrapper&lt;/a&gt; and Json.Net (get it from NuGet). Note that I modified the Ghostscript wrapper to use the gsdll64.dll instead of the gs32dll.dll to make it work more easily with my IIS.&lt;/p&gt;
&lt;p&gt;The actual viewer.aspx are modifed to show the images:&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: #f4f4f4;"&gt;
&lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum1" style="color: #606060;"&gt; 1:&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;html&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;xmlns&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="http://www.w3.org/1999/xhtml"&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum2" style="color: #606060;"&gt; 2:&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;head&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="server"&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum3" style="color: #606060;"&gt; 3:&lt;/span&gt;     &lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;title&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;title&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum4" style="color: #606060;"&gt; 4:&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;head&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum5" style="color: #606060;"&gt; 5:&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;body&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum6" style="color: #606060;"&gt; 6:&lt;/span&gt;     &lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;form&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="form1"&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="server"&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum7" style="color: #606060;"&gt; 7:&lt;/span&gt;     &lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;div&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum8" style="color: #606060;"&gt; 8:&lt;/span&gt;         &lt;span style="background-color: #ffff00;"&gt;&amp;lt;%&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum1" style="color: #606060;"&gt; 1:&lt;/span&gt;  &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt;(!previewMode) { &lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;!--CRLF--&gt;&lt;span style="background-color: #ffff00;"&gt;%&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum9" style="color: #606060;"&gt; 9:&lt;/span&gt;         &lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;div&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;style&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="position:fixed; top:0; background:#cccccc; width:100%; color:white;margin:3px; font-family:'Segoe UI', Calibri;"&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;amp;nbsp;&lt;/span&gt;PDF Preview &lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;a&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;href&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="&amp;lt;%=origdoc%&amp;gt;"&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;Open PDF&lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;a&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;div&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum10" style="color: #606060;"&gt; 10:&lt;/span&gt;         &lt;span style="background-color: #ffff00;"&gt;&amp;lt;%&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum1" style="color: #606060;"&gt; 1:&lt;/span&gt;  } &lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;!--CRLF--&gt;&lt;span style="background-color: #ffff00;"&gt;%&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum11" style="color: #606060;"&gt; 11:&lt;/span&gt;         &lt;span style="background-color: #ffff00;"&gt;&amp;lt;%&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum1" style="color: #606060;"&gt; 1:&lt;/span&gt; =metadata &lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;!--CRLF--&gt;&lt;span style="background-color: #ffff00;"&gt;%&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum12" style="color: #606060;"&gt; 12:&lt;/span&gt;        &lt;span style="background-color: #ffff00;"&gt;&amp;lt;%&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum1" style="color: #606060;"&gt; 1:&lt;/span&gt; =images &lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;!--CRLF--&gt;&lt;span style="background-color: #ffff00;"&gt;%&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum13" style="color: #606060;"&gt; 13:&lt;/span&gt;     &lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;div&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum14" style="color: #606060;"&gt; 14:&lt;/span&gt;     &lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;form&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum15" style="color: #606060;"&gt; 15:&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;body&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum16" style="color: #606060;"&gt; 16:&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;html&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When done, go into your Search center and create a new result type for PDFs that uses the Word Item display template.&lt;/p&gt;
&lt;p&gt;It will give a search result like this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85-metablogapi/7380.pdf_5F00_preview_5F00_4E1A25E0.png"&gt;&lt;img style="display: inline; background-image: none;" title="pdf_preview" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85-metablogapi/6204.pdf_5F00_preview_5F00_thumb_5F00_63B45E7D.png" alt="pdf_preview" width="727" height="375" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you click on a PDF in a document library it will open in a full screen PDF previewer like this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85-metablogapi/5621.pdf_5F00_fullscreen_5F00_preview_5F00_489B8F6F.png"&gt;&lt;img style="display: inline; background-image: none;" title="pdf_fullscreen_preview" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85-metablogapi/1423.pdf_5F00_fullscreen_5F00_preview_5F00_thumb_5F00_2CAA5A77.png" alt="pdf_fullscreen_preview" width="519" height="593" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;That&amp;rsquo;s it. Clicking the search result doesn&amp;rsquo;t work (since I&amp;rsquo;ve just used the Word Item templates and my WOPI App doesn&amp;rsquo;t support edit). I&amp;rsquo;ve left modifying the display template to fit properly as an exercise for the reader &lt;img class="wlEmoticon wlEmoticon-smile" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85-metablogapi/8863.wlEmoticon_2D00_smile_5F00_31406531.png" alt="Smile" /&gt;&lt;/p&gt;
&lt;p&gt;If you read the &lt;a href="http://www.wictorwilen.se/sharepoint-2013-building-your-own-wopi-client-part-1" target="_blank"&gt;original blog series&lt;/a&gt; you should get this working. If you didn&amp;rsquo;t go do it now (to make more sense of this &lt;img class="wlEmoticon wlEmoticon-smile" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85-metablogapi/8863.wlEmoticon_2D00_smile_5F00_31406531.png" alt="Smile" /&gt;)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you have any questions don&amp;rsquo;t hesitate to contact me.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10365229" width="1" height="1"&gt;</description></item><item><title>Utilizing Web Apps 2010 to get PowerPoint search document previews of SharePoint 2010 content in SharePoint 2013 search</title><link>http://blogs.msdn.com/b/murads/archive/2012/10/11/utilizing-web-apps-2010-to-get-powerpoint-previews-of-sharepoint-2010-content-from-sharepoint-2013-search.aspx</link><pubDate>Thu, 11 Oct 2012 09:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10358683</guid><dc:creator>Murad Sæter</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/murads/rsscomments.aspx?WeblogPostID=10358683</wfw:commentRss><comments>http://blogs.msdn.com/b/murads/archive/2012/10/11/utilizing-web-apps-2010-to-get-powerpoint-previews-of-sharepoint-2010-content-from-sharepoint-2013-search.aspx#comments</comments><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: x-small;" size="2"&gt;&lt;span style="font-size: x-small;" size="2"&gt;With the new SharePoint 2013 (preview) and Office Web Apps (OWA) there are beautiful previews of PowerPoint (and Word) documents. The requirement is that the documents are stored in SharePoint 2013 as well. There are rumors that you should get previews of content stored in SharePoint 2010, but until now I haven&amp;rsquo;t seen this happen. The reason has to do with oauth and the fact that SharePoint 2010 doesn&amp;rsquo;t support that. Someone will probably solve it at some point, but until then I&amp;rsquo;ll show you how to use the SP2010 OWA to show previews for SP2010 powerpoints.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: x-small;" size="2"&gt;&lt;span style="font-size: x-small;" size="2"&gt;To do this you need to familiar with the Display Templates in SP2013. Steve Peschka has written some good articles about this in his &lt;/span&gt;&lt;/span&gt;&lt;a title="Using Query Rules, Result Types and Display Templates for a Custom Search Sales Report in SharePoint 2013" href="http://blogs.technet.com/b/speschka/archive/2012/07/23/using-query-rules-result-types-and-display-templates-for-a-custom-search-sales-report-in-sharepoint-2013.aspx" target="_blank"&gt;&lt;span style="font-size: x-small;" size="2"&gt;&lt;span style="font-size: x-small;" size="2"&gt;blog&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: x-small;" size="2"&gt;&lt;span style="font-size: x-small;" size="2"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: x-small;" size="2"&gt;&lt;span style="font-size: x-small;" size="2"&gt;I&amp;rsquo;ll start by explaining how SP2010 implements previews:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span style="font-size: x-small;" size="2"&gt;&lt;span style="font-size: x-small;" size="2"&gt;During crawling, the crawler detects if a document has a preview available, and populates the managed property ServerRedirectedURL. Fortunately, it does exactly the same in SP2013.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: x-small;" size="2"&gt;If the ServerRedirectedURL managed property is available during result rendering, a JSONP call against a the wacproxy.ashx will be performed. The wacproxy.ash returns a list of thumbnails which can be showed to the user.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span style="font-size: x-small;" size="2"&gt;&lt;span style="font-size: x-small;" size="2"&gt;So, now we can simply do the same with SP2013. I&amp;rsquo;ll do this in the existing PowerPoint display templates.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h1&gt;&lt;/h1&gt;
&lt;h1&gt;&lt;span style="font-size: x-small;" size="2"&gt;&lt;span style="font-size: large;" size="5"&gt;Item thumbnail&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: x-small;" size="2"&gt;&lt;span style="font-size: x-small;" size="2"&gt;The Item_PowerPoint.html (you find all the Display Templates under Site Settings &amp;ndash;&amp;gt; Master pages and page layouts) is used by all ppt&amp;rsquo;s, regardless of where they are stored. As it turns out, SP2013 content has a couple of more managed properties called ServerRedirectedPreviewURL and ServerRedirectedEmbedURL which means we can differentiate the content types without creating another Result type for SP2010 content.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: x-small;" size="2"&gt;&lt;span style="font-size: x-small;" size="2"&gt;In the file I add the following to detect SP2010 ppts:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: #f4f4f4;"&gt;
&lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum1" style="color: #606060;"&gt; 1:&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt;(!$isNull(ctx.CurrentItem.ServerRedirectedPreviewURL)) &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum2" style="color: #606060;"&gt; 2:&lt;/span&gt; { &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum3" style="color: #606060;"&gt; 3:&lt;/span&gt;     &lt;span style="color: #008000;"&gt;// SP2013 &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum4" style="color: #606060;"&gt; 4:&lt;/span&gt;     ctx.CurrentItem.csr_PreviewImage = ctx.CurrentItem.ServerRedirectedPreviewURL; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum5" style="color: #606060;"&gt; 5:&lt;/span&gt;     ctx.CurrentItem.csr_PathLength = Srch.U.pathTruncationLengthWithPreview; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum6" style="color: #606060;"&gt; 6:&lt;/span&gt; } &lt;span style="color: #0000ff;"&gt;else&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt;(!Srch.U.n(ctx.CurrentItem.ServerRedirectedURL) &amp;amp;&amp;amp; Srch.U.n(ctx.CurrentItem.ServerRedirectedEmbedURL)) { &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum7" style="color: #606060;"&gt; 7:&lt;/span&gt;     // SP2010&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: x-small;" size="2"&gt;&lt;/span&gt;For the item view in the main result set we only show a small thumbnail. To make sure the rest of the page has finished rendered prior to we start our work, we utilize a function to add a callback that is run post rendering of the page. The method called &amp;ldquo;AddPostRenderCallback&amp;rdquo;. The post render function is run after all results has been rendered, so we don&amp;rsquo;t have access to the current result unless we store it:&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: #f4f4f4;"&gt;
&lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum1" style="color: #606060;"&gt; 1:&lt;/span&gt; var currentItem = ctx.CurrentItem;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Then we add the post render function:&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: #f4f4f4;"&gt;
&lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum1" style="color: #606060;"&gt; 1:&lt;/span&gt; AddPostRenderCallback(ctx, function() { &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum2" style="color: #606060;"&gt; 2:&lt;/span&gt;     &lt;span style="color: #008000;"&gt;// wac proxy url &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum3" style="color: #606060;"&gt; 3:&lt;/span&gt;     var MobilePresentation = currentItem.SiteName + &lt;span style="color: #006080;"&gt;'/_vti_bin/wacproxy.ashx?redirect='&lt;/span&gt; + encodeURIComponent(currentItem.ServerRedirectedURL) + &lt;span style="color: #006080;"&gt;'&amp;amp;spsite='&lt;/span&gt; + encodeURIComponent(currentItem.SiteName) + &lt;span style="color: #006080;"&gt;'&amp;amp;docType=pptx&amp;amp;callbackFunctionName=?'&lt;/span&gt;; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum4" style="color: #606060;"&gt; 4:&lt;/span&gt;     var func = &lt;span style="color: #006080;"&gt;"parent.window.ThumbnailCallbackFn_"&lt;/span&gt; + id + &lt;span style="color: #006080;"&gt;"= function(images) { processImageThumbnail('"&lt;/span&gt;+id+&lt;span style="color: #006080;"&gt;"', images); }"&lt;/span&gt;; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum5" style="color: #606060;"&gt; 5:&lt;/span&gt;     eval(func); &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum6" style="color: #606060;"&gt; 6:&lt;/span&gt;     &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum7" style="color: #606060;"&gt; 7:&lt;/span&gt;     jq.ajax({ &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum8" style="color: #606060;"&gt; 8:&lt;/span&gt;           dataType: &lt;span style="color: #006080;"&gt;'jsonp'&lt;/span&gt;, &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum9" style="color: #606060;"&gt; 9:&lt;/span&gt;           url: MobilePresentation, &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum10" style="color: #606060;"&gt; 10:&lt;/span&gt;           jsonpCallback: &lt;span style="color: #006080;"&gt;'ThumbnailCallbackFn_'&lt;/span&gt; + id, &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum11" style="color: #606060;"&gt; 11:&lt;/span&gt;           success: function (data) { &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum12" style="color: #606060;"&gt; 12:&lt;/span&gt;           }, &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum13" style="color: #606060;"&gt; 13:&lt;/span&gt;         error: function(data) { &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum14" style="color: #606060;"&gt; 14:&lt;/span&gt;         }  &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum15" style="color: #606060;"&gt; 15:&lt;/span&gt;     }); &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum16" style="color: #606060;"&gt; 16:&lt;/span&gt;  });&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In the code we create the wacproxy URL based on ServerRedirectedURL. We create a delegate function will be called by the JSONP callback. The delegate function call the processImageThumbnail which does actual rendering of the thumbnail into the page:&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: #f4f4f4;"&gt;
&lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum1" style="color: #606060;"&gt; 1:&lt;/span&gt; function processImageThumbnail(id, images) { &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum2" style="color: #606060;"&gt; 2:&lt;/span&gt; &amp;uml;    &lt;span style="color: #008000;"&gt;// the default width is 320px, we want' 100px &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum3" style="color: #606060;"&gt; 3:&lt;/span&gt;     var tmp=images.replace(/width\=320/g,&lt;span style="color: #006080;"&gt;'width=100'&lt;/span&gt;); &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum4" style="color: #606060;"&gt; 4:&lt;/span&gt;     tmp=tmp.replace(/height\=240/g,&lt;span style="color: #006080;"&gt;"height=56"&lt;/span&gt;); &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum5" style="color: #606060;"&gt; 5:&lt;/span&gt;     var a = eval(&lt;span style="color: #006080;"&gt;'('&lt;/span&gt;+tmp+&lt;span style="color: #006080;"&gt;')'&lt;/span&gt;)[&lt;span style="color: #006080;"&gt;'images'&lt;/span&gt;]; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum6" style="color: #606060;"&gt; 6:&lt;/span&gt;     var thumbnail=a[0]; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum7" style="color: #606060;"&gt; 7:&lt;/span&gt;     &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum8" style="color: #606060;"&gt; 8:&lt;/span&gt;     var previewHtml = String.format(&lt;span style="color: #006080;"&gt;'&amp;lt;div id="{0}_item_itemPreview" class="custom-srch-item-previewContainer"&amp;gt;&amp;lt;a href="{1}" class="ms-srch-item-previewLink" target="_blank"&amp;gt;&amp;lt;img class="ms-srch-item-preview" src="{2}" alt="{3}"/&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;'&lt;/span&gt;, &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum9" style="color: #606060;"&gt; 9:&lt;/span&gt;                     id, currentItem.ServerRedirectedURL, thumbnail, &lt;span style="color: #006080;"&gt;"Open in New Window"&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum10" style="color: #606060;"&gt; 10:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum11" style="color: #606060;"&gt; 11:&lt;/span&gt;     &lt;span style="color: #008000;"&gt;// Current description needs to be narrow &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum12" style="color: #606060;"&gt; 12:&lt;/span&gt;     jq(&lt;span style="color: #006080;"&gt;'#'&lt;/span&gt;+id+&lt;span style="color: #006080;"&gt;'_item_itemBody'&lt;/span&gt;).addClass(&lt;span style="color: #006080;"&gt;"ms-srch-item-summaryPreview"&lt;/span&gt;); &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum13" style="color: #606060;"&gt; 13:&lt;/span&gt;     &lt;span style="color: #008000;"&gt;// Add thumbnail &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum14" style="color: #606060;"&gt; 14:&lt;/span&gt;     jq(&lt;span style="color: #006080;"&gt;'#'&lt;/span&gt;+id+&lt;span style="color: #006080;"&gt;'_item_itemBody'&lt;/span&gt;).after(previewHtml); &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum15" style="color: #606060;"&gt; 15:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&amp;nbsp;&amp;nbsp;
&lt;p&gt;The html is very similar to how it looks when a SP2013 thumbnail is shown, by reusing most of the CSS classes.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h1&gt;&lt;span style="font-size: large;" size="5"&gt;Hover Panel&lt;/span&gt;&lt;/h1&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When it comes to the hover panel is very similar. We change the Item_PowerPoint_HoverPanel.html by adding a section that handles SP2010.&lt;/p&gt;
&lt;p&gt;First some code to display the black loading box:&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: #f4f4f4;"&gt;
&lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum1" style="color: #606060;"&gt; 1:&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;div&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;class&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="ms-srch-hover-viewerContainer"&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;style&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="height:400px;"&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="sp2010viewer__#= id =#_"&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum2" style="color: #606060;"&gt; 2:&lt;/span&gt;     &lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;div&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;class&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="sp2010"&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;style&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="height:400px;background-color:black;color:white;font-family: Segoe UI Light, Segoe UI,Segoe,Tahoma,Helvetica,Arial,sans-serif;font-size:2.5em;"&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;br&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;/&amp;gt;&lt;/span&gt;PowerPoint Web App 2010&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;br&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;br&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;/&amp;gt;&lt;/span&gt;Working on it!&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;br&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;br&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;div&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum3" style="color: #606060;"&gt; 3:&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;div&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;It looks like this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85-metablogapi/5287.sp2010_5F00_loading_5F00_64DE65DF.png"&gt;&lt;img width="395" height="328" title="sp2010_loading" style="display: inline; background-image: none;" alt="sp2010_loading" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85-metablogapi/3122.sp2010_5F00_loading_5F00_thumb_5F00_2146B4BD.png" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The rest of the code is very similar to the normal item, expect for the HTML generated.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m not explaining it here, this is an exercise for the reader. Or download the attached code.&lt;/p&gt;
&lt;p&gt;The full result looks like this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85-metablogapi/6305.sp2013_5F00_sp2010preview_5F00_0B10996B.png"&gt;&lt;img width="666" height="382" title="sp2013_sp2010preview" style="display: inline; background-image: none;" alt="sp2013_sp2010preview" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85-metablogapi/3225.sp2013_5F00_sp2010preview_5F00_thumb_5F00_7C194483.png" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h1&gt;Installing the sample code&lt;/h1&gt;
&lt;p&gt;The zip file contains&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Code fragments which should be inserted into Item_PowerPoint.html and Item_PowerPoint_HoverPanel.html&lt;/li&gt;
&lt;li&gt;screen.css (modifed from the ootb easyslider css)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The zip does &lt;strong&gt;NOT &lt;/strong&gt;contain the follow required files.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Jquery&lt;/li&gt;
&lt;li&gt;EasySlider1.7.js&lt;/li&gt;
&lt;li&gt;prt.png from Office Web Apps 2013&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Install it:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Edit Item_PowerPoint.html, and insert the contents of Item_PowerPoint_code.txt at line 36 (delete the })&lt;/li&gt;
&lt;li&gt;Edit Item_PowerPoint_HovelPanel.html, and insert the contents of Item_PowerPoint_HoverPanel_code.txt at line 49 (delete the })&lt;/li&gt;
&lt;li&gt;Upload screen.css to Pages folder of your search site (same folder as results.aspx)&lt;/li&gt;
&lt;li&gt;Download easyslider1.7.js and place in the same folder.&lt;/li&gt;
&lt;li&gt;Download jquery.1.7.2.js and place in the same folder (or use a CDN)&lt;/li&gt;
&lt;li&gt;Get prt.png from your Office Web Apps 2013 server and place in the same folder. On your OWA you can get file from &lt;a href="http://&lt;server&gt;/p/PptResources/1033/prt.png"&gt;/p/PptResources/1033/prt.png"&amp;gt;http://&amp;lt;server&amp;gt;/p/PptResources/1033/prt.png&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Make sure all files are commited and published.&lt;/li&gt;
&lt;li&gt;Add a Script Editor webpart on your search page, and add the following code:&lt;/li&gt;
&lt;/ol&gt;
&lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: #f4f4f4;"&gt;
&lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum1" style="color: #606060;"&gt; 1:&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;script&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;type&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="text/javascript"&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;src&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="http://code.jquery.com/jquery-1.7.2.js"&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;script&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum1" style="color: #606060;"&gt; 1:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum2" style="color: #606060;"&gt; 2:&lt;/span&gt; &amp;lt;script type=&lt;span style="color: #006080;"&gt;"text/javascript"&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum3" style="color: #606060;"&gt; 3:&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;var&lt;/span&gt; jq = jQuery.noConflict();&lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;!--CRLF--&gt;&lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;script&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum1" style="color: #606060;"&gt; 1:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum2" style="color: #606060;"&gt; 2:&lt;/span&gt; &amp;lt;script type=&lt;span style="color: #006080;"&gt;"text/javascript"&lt;/span&gt; src=&lt;span style="color: #006080;"&gt;"easySlider1.7.js"&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;!--CRLF--&gt;&lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;script&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span id="lnum2" style="color: #606060;"&gt; 2:&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;link&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;href&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="screen.css"&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;rel&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="stylesheet"&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;type&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="text/css"&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;media&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="screen"&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This will load jquery and the easyslider javascript. Jquery cannot be used with the dollar ($), since this already is used internally in the display templates. In this sample jquery is therefore defined as jq.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85/5618.sp2010_5F00_powerpoint_5F00_preview.zip" target="_blank"&gt;Download the ZIP file&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;That should be it. Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10358683" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/murads/archive/tags/sharepoint+2013/">sharepoint 2013</category><category domain="http://blogs.msdn.com/b/murads/archive/tags/search+document+preview/">search document preview</category></item><item><title>Details of the automatic spelling suggestions in FAST Search for SharePoint 2010</title><link>http://blogs.msdn.com/b/murads/archive/2012/08/24/details-of-the-automatic-spelling-suggestions-in-fast-search-for-sharepoint-2010.aspx</link><pubDate>Fri, 24 Aug 2012 10:39:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10343228</guid><dc:creator>Murad Sæter</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/murads/rsscomments.aspx?WeblogPostID=10343228</wfw:commentRss><comments>http://blogs.msdn.com/b/murads/archive/2012/08/24/details-of-the-automatic-spelling-suggestions-in-fast-search-for-sharepoint-2010.aspx#comments</comments><description>&lt;p&gt;It&amp;rsquo;s been a well known fact that you cannot change the automatic spelling suggestions you get with FAST Search for SharePoint 2010. Either you go with the out of the box dictionaries, or you get it automatically aligned with your crawled content. As it &lt;a title="How to utilize the spelltuner to add or boost terms for spellchecking" href="http://support.microsoft.com/kb/2592062" target="_blank"&gt;turns out&lt;/a&gt;, this is possible after all!&lt;/p&gt;
&lt;p&gt;After I found the article from support (&lt;a href="http://support.microsoft.com/kb/2592062" target="_blank"&gt;How to utilize the spelltuner to add or boost terms for spellchecking&lt;/a&gt;), I wanted to understand all the details of the spelltuning. So here it goes.&lt;/p&gt;
&lt;p&gt;Normal process:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The document processor TermExtractor extracts the terms and writes them to a file in $FASTSEARCH\data\termextractor. The file name will be %PORT%_%HOSTNAME%.out.gz. The files contain one line per term, on the format &amp;lt;lang&amp;gt; &amp;lt;term&amp;gt; &amp;lt;frequency&amp;gt;&lt;/li&gt;
&lt;li&gt;Every 10&lt;sup&gt;th&lt;/sup&gt; batch (configurable for debugging purposes in $FASTSEARCH\etc\processors\TermExtractor.xml) the document processor will upload the terms to the resource store. (stored in $FASTSEARCH\components\resourcestore\dictionaries\spelltuner)&lt;/li&gt;
&lt;li&gt;The spelltuner runs as a continuous process in the node controller. Every 60 minutes it downloads the files the document processor has uploaded to the resource store.&lt;/li&gt;
&lt;li&gt;Every 24 hours the spelltuner will generate a new dictionary (one per language) and uploaded to the resource store. (stored in $FASTSEARCH\components\resourcestore\dictionaries\spellcheck)&lt;/li&gt;
&lt;li&gt;If there were any changes to one or more dictionaries the spelltuner will notify the qrserver, and it will reload the dictionary.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Custom tuning:&lt;/p&gt;
&lt;p&gt;To inject your own words into a dictionary, create your own gzipped file on the format &amp;lt;lang&amp;gt; &amp;lt;term&amp;gt; &amp;lt;frequency&amp;gt; and store it in $FASTSEARCH\components\resourcestore\dictionaries\spelltuner.&lt;/p&gt;
&lt;p&gt;Spelltuner parameters:&lt;/p&gt;
&lt;p&gt;The spelltuner runs with some preconfigured parameters which might need to be changed. The most interesting one for small indexes is the --wordcount-threshold which by default is 100000. This means that a minimum of 100000 words is required for a language in order to trigger spell tuning. For a small index this parameter might need to be set as low as 1000. The parameter can be changed in NodeConf.xml. However, since changing this file is not supported (and might be overwritten in an update), an alternative would be to stop the spelltuner (nctrl stop spelltuner) and run it manually or in a scheduled task.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;DISCLAIMER: This information was extracted by myself after digging into an FS4SP installation and the existing documentation. It is not official documentation of any sort.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10343228" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/murads/archive/tags/fs4sp/">fs4sp</category><category domain="http://blogs.msdn.com/b/murads/archive/tags/spelltuner/">spelltuner</category><category domain="http://blogs.msdn.com/b/murads/archive/tags/FAST+Search+for+SharePoint+2010/">FAST Search for SharePoint 2010</category><category domain="http://blogs.msdn.com/b/murads/archive/tags/spelling+suggestions/">spelling suggestions</category><category domain="http://blogs.msdn.com/b/murads/archive/tags/did+you+mean/">did you mean</category></item><item><title>No Code secure search with FAST Search for SharePoint 2010</title><link>http://blogs.msdn.com/b/murads/archive/2012/05/03/no-code-secure-search-with-fast-search-for-sharepoint-2010.aspx</link><pubDate>Thu, 03 May 2012 13:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10300404</guid><dc:creator>Murad Sæter</dc:creator><slash:comments>9</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/murads/rsscomments.aspx?WeblogPostID=10300404</wfw:commentRss><comments>http://blogs.msdn.com/b/murads/archive/2012/05/03/no-code-secure-search-with-fast-search-for-sharepoint-2010.aspx#comments</comments><description>&lt;h1&gt;Introduction&lt;/h1&gt;  &lt;p&gt;Implementing secure database search on the item level with FastSearch for SharePoint 2010 (FS4SP) has been a somewhat confusing journey for me.&lt;/p&gt;  &lt;p&gt;At the start I had some questions:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Can I use BCS?&lt;/li&gt;    &lt;li&gt;Must I write .NET assembly connector?&lt;/li&gt;    &lt;li&gt;Can I use FAST’s jdbcconnector?&lt;/li&gt;  &lt;/ul&gt;  &lt;p&gt;The short answer is yes, no and yes. The long answer will follow below.&lt;/p&gt;  &lt;h1&gt;Secure search&lt;/h1&gt;  &lt;p&gt;To support secure search at the item level each document will have to be associated with an ACL, describing who has access to the document. At query time the user's group memberships will be looked up against Active Directory and added to the query to match against the ACLs stored in the index. This way only documents the user has access to will be shown in the search result. Out the box, FS4SP will only support Active Directory as the user directory.&lt;/p&gt;  &lt;p&gt;Enabling secure search on database content is therefore only a matter of adding a security descriptor to each row, describing who should be able to read this row. This sounds easy enough, but the question is still; what should this ACL look like, and how do I put it on the correct place in my index.&lt;/p&gt;  &lt;h1&gt;Using BCS&lt;/h1&gt;  &lt;p&gt;As an example I've used the AdventureWorksDW database and the table DimProduct. The table has been altered to include a column named SecurityDescriptor of type varbinary(MAX). I started with SharePoint Designer (SPD) and created my simple model with ReadList and ReadItem methods. This model was exported from SPD to a BDCM (XML) file. The model doesn’t include any information about where to fetch the security descriptor, it is however described on various places on the internet how to enable security on the item level in the model. &lt;a href="http://msdn.microsoft.com/en-us/library/gg294169.aspx"&gt;MSDN&lt;/a&gt; has one example. Note that you only need to update the SpecificFinder method, no BinarySecurityDescriptorAccessor is needed.&lt;/p&gt;  &lt;p&gt;I'll recap the steps below, but please check MSDN for the correct placement in your bdcm (or see the attached example):&lt;/p&gt;  &lt;p&gt;1. Add a new TypeDescriptor in the SpecificFinder, this will read a bytearray from the column named SecurityDescriptor:&lt;/p&gt;  &lt;div style="margin: 0px; padding: 0px; float: none; display: inline;" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:75da409a-7ed0-4d1b-a2ec-16237e4bb001" class="wlWriterEditableSmartContent"&gt;&lt;pre style=" width: 736px; height: 105px;background-color:White;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;TypeDescriptor &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;TypeName&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&amp;quot;&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; IsCollection&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; Name&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;SecurityDescriptor&amp;quot;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
 &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;TypeDescriptors&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
 &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;TypeDescriptor &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;TypeName&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;System.Byte&amp;quot;&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; Name&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;SecurityDescriptorElement&amp;quot;&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
 &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;TypeDescriptors&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;TypeDescriptor&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;2. Add a reference to the the SecurityDescriptor in the property WindowsSecurityDescriptorField (still on SpecificFinder)&lt;/p&gt;

&lt;div style="margin: 0px; padding: 0px; float: none; display: inline;" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:392b4a1a-dc47-41af-aba2-51e7b86bfcbc" class="wlWriterEditableSmartContent"&gt;&lt;pre style=" width: 706px; height: 124px;background-color:White;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;MethodInstance &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;Type&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;SpecificFinder&amp;quot;&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; ReturnParameterName&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;DimProductRead Item&amp;quot;&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; ReturnTypeDescriptorPath&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;DimProductRead Item[0]&amp;quot;&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; Default&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; Name&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;DimProductRead Item&amp;quot;&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; DefaultDisplayName&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;Read Item AdventureWorksDW&amp;quot;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
  &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Properties&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
 &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Property &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;Name&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;WindowsSecurityDescriptorField&amp;quot;&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; Type&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;System.String&amp;quot;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;SecurityDescriptor&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;Property&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;
 &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;Properties&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;

&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;3. Make sure to remove the UseClientCachingForSearch&lt;/p&gt;

&lt;pre style="background: white; color: black; font-family: consolas;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Property&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;#160;&lt;/span&gt;&lt;span style="color: red;"&gt;Name&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue;"&gt;UseClientCachingForSearch&lt;/span&gt;&amp;quot;&lt;span style="color: blue;"&gt;&amp;#160;&lt;/span&gt;&lt;span style="color: red;"&gt;Type&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue;"&gt;System.String&lt;/span&gt;&amp;quot;&lt;span style="color: blue;"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Property&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;4. Also make sure you have &amp;quot;ShowInSearchUI&amp;quot; (should already be there)&lt;/p&gt;

&lt;p&gt;Now, import your model using Central Admin, and once you have your SecurityDescriptors in place you should be ready to crawl.&lt;/p&gt;

&lt;h2&gt;Creating the ACL&lt;/h2&gt;

&lt;p&gt;Finding the correct format of the Security Descriptor (ACL) and how to store it in SQL server was the most difficult part digging out. The Security Descriptor should be stored in binary format in the column referenced in the BDC model. On &lt;a title="MSDN" href="http://msdn.microsoft.com/en-us/library/gg294169.aspx"&gt;MSDN&lt;/a&gt; there is a C# code snippet that retrieves a sample windows Security Descriptor for a specific user/group in binary as a byte array. I've extended the snippet to update my SecurityDescriptor column (I’m using the same ACL for all rows):&lt;/p&gt;

&lt;div style="margin: 0px; padding: 0px; float: none; display: inline;" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:f7cf52ec-1513-442b-bf7d-620216539a78" class="wlWriterEditableSmartContent"&gt;&lt;pre style=" width: 608px; height: 842px;background-color:White;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #0000FF;"&gt;static&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; Main(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt;[] args)
{
    Program sdl &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; Program();
    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;byte&lt;/span&gt;&lt;span style="color: #000000;"&gt;[] b &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; sdl.GetSecurityDescriptor(&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Contoso&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;SearchUsers&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;);

    SqlConnection cn &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; SqlConnection();
    cn.ConnectionString &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Data Source=demo2010a;Integrated Security=True&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;;
    cn.Open();

    SqlCommand cmd &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; SqlCommand(&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;UPDATE [AdventureWorksDW].[dbo].[DimProduct] SET [SecurityDescriptor] = @SecurityDescriptor&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;, cn);
    cmd.Parameters.Add(&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;@SecurityDescriptor&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;, System.Data.SqlDbType.VarBinary);
    cmd.Parameters[&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;@SecurityDescriptor&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;].Value &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; b;

    cmd.ExecuteNonQuery();

    cn.Close();

    Console.WriteLine(b.ToString());
}

&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; Byte[] GetSecurityDescriptor(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; domain, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; username)
{
    NTAccount acc &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; NTAccount(domain, username);
    SecurityIdentifier sid &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; (SecurityIdentifier)acc.Translate(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;typeof&lt;/span&gt;&lt;span style="color: #000000;"&gt;(SecurityIdentifier));
    CommonSecurityDescriptor sd &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; CommonSecurityDescriptor(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;false&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;false&lt;/span&gt;&lt;span style="color: #000000;"&gt;, ControlFlags.None, sid, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;);
    sd.SetDiscretionaryAclProtection(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;true&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;false&lt;/span&gt;&lt;span style="color: #000000;"&gt;);    &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;Deny access to all users.   &lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #000000;"&gt;    SecurityIdentifier everyone &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; SecurityIdentifier(WellKnownSidType.WorldSid, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;);
    sd.DiscretionaryAcl.RemoveAccess(AccessControlType.Allow, everyone, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;unchecked&lt;/span&gt;&lt;span style="color: #000000;"&gt;((&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;/span&gt;&lt;span style="color: #800080;"&gt;0xffffffffL&lt;/span&gt;&lt;span style="color: #000000;"&gt;), InheritanceFlags.None, PropagationFlags.None);
    &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;Grant full access to a specified user.   &lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #000000;"&gt;    sd.DiscretionaryAcl.AddAccess(AccessControlType.Allow, sid, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;unchecked&lt;/span&gt;&lt;span style="color: #000000;"&gt;((&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;/span&gt;&lt;span style="color: #800080;"&gt;0xffffffffL&lt;/span&gt;&lt;span style="color: #000000;"&gt;), InheritanceFlags.None, PropagationFlags.None);

    Console.WriteLine(sd.GetSddlForm(AccessControlSections.All));

    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;byte&lt;/span&gt;&lt;span style="color: #000000;"&gt;[] secDes &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; Byte[sd.BinaryLength];
    sd.GetBinaryForm(secDes, &lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;); 
    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; secDes;
}
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;div align="left"&gt;&lt;span style="font-family: segoe ui;" face="Segoe UI"&gt;&lt;/span&gt;

  &lt;p&gt;Once you've run the code snippet above you should be ready crawl, and any users in the SearchUsers groups should be able to see the secured rows in the search results.&lt;/p&gt;
&lt;/div&gt;

&lt;h2 class="scroll"&gt;JDBC format&lt;/h2&gt;

&lt;p&gt;The BCS crawler will submit the SecurityDescriptor in string format (SDDL) into the docaclms property. During content processing the docaclms property will be converted to an internal format which consists of the SID's of each user/group which allowed or denied access to the document. Each SID is base32 encoded and put into the property docacl. The docacl property is the one which is actually filtered against at query time. When using the jdbc connector one has the possibility to write directly to the docacl property. To create a correct string use the Get-FASTSearchSecurityEncodedSid:&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family: courier new; background-color: rgb(255, 255, 255);" face="Courier New"&gt;PS C:\FASTSearch\bin&amp;gt; Get-FASTSearchSecurityEncodedSid -User Contoso\danj
    &lt;br /&gt;S-1-5-21-331390976-2650875657-2422772959-1705 

    &lt;br /&gt;aecqaaaaaaaakfiaaaaabigacmesoam525kgrefjayaaa 

    &lt;br /&gt;PS C:\FASTSearch\bin&amp;gt; Get-FASTSearchSecurityEncodedSid -User Contoso\SearchUsers&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family: courier new; background-color: rgb(255, 255, 255);" face="Courier New"&gt;S-1-5-21-331390976-2650875657-2422772959-2004 
    &lt;br /&gt;aecqaaaaaaaakfiaaaaabigacmesoam525kgregua3aaa&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;The cmdlet will output both the SID and the encoded SID. To create a proper acl prefix each SID with &amp;quot;win&amp;quot; (allow) or &amp;quot;9win&amp;quot;&amp;#160; (deny). To allow CONTOSO\danj and CONTOSO\SearchUsers, the docacl would be&lt;/p&gt;

&lt;p&gt;winaecqaaaaaaaakfiaaaaabigacmesoam525kgrefjayaaa; winaecqaaaaaaaakfiaaaaabigacmesoam525kgregua3aaa&lt;/p&gt;

&lt;p&gt;The ACL above could either be put into the SQL table as showed below, or it can it can be hardcoded in the SQL query of the jdbc connector configuration:&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family: courier new;" face="Courier New"&gt;SELECT [ProductKey], 'winaecqaaaaaaaakfiaaaaabigacmesoam525kgrefjayaaa; winaecqaaaaaaaakfiaaaaabigacmesoam525kgregua3aaa' as docacl &lt;/span&gt;&lt;/p&gt;

&lt;p&gt;See the attached jdbc connector configuration for a complete example.&lt;/p&gt;

&lt;h1&gt;Database sample&lt;/h1&gt;

&lt;p&gt;The screenshot below shows a couple of sample rows. docaclwin contains the base32 encoded SID values, and SecurityDescriptor contains the binary Security Descriptor.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85-metablogapi/8203.image_5F00_56F889B0.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85-metablogapi/7610.image_5F00_thumb_5F00_0DF267EA.png" width="573" height="170" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10300404" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-30-04-04/SampleFiles.zip" length="9297" type="application/zip" /><category domain="http://blogs.msdn.com/b/murads/archive/tags/fastsearch+for+sharepoint/">fastsearch for sharepoint</category><category domain="http://blogs.msdn.com/b/murads/archive/tags/search/">search</category><category domain="http://blogs.msdn.com/b/murads/archive/tags/jdbcconnector/">jdbcconnector</category><category domain="http://blogs.msdn.com/b/murads/archive/tags/fast/">fast</category><category domain="http://blogs.msdn.com/b/murads/archive/tags/bcs/">bcs</category></item><item><title>Using FASTSearch for SharePoint 2010 to index Exchange public folders</title><link>http://blogs.msdn.com/b/murads/archive/2011/10/04/using-fastsearch-for-sharepoint-2010-to-index-exchange-public-folders.aspx</link><pubDate>Tue, 04 Oct 2011 10:29:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10219702</guid><dc:creator>Murad Sæter</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/murads/rsscomments.aspx?WeblogPostID=10219702</wfw:commentRss><comments>http://blogs.msdn.com/b/murads/archive/2011/10/04/using-fastsearch-for-sharepoint-2010-to-index-exchange-public-folders.aspx#comments</comments><description>&lt;p&gt;Indexing of Exchange public folders is one of the less used options in FASTSearch for SharePoint. At least so it seems; I can't find any examples of people setting it up.&lt;/p&gt;
&lt;p&gt;In this example I'm using the SharePoint 2010 demo VHDs available here: &lt;a title="2010 Information Worker Demonstration and Evaluation Virtual Machine (SP1)" href="http://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;amp;id=27417"&gt;2010 Information Worker Demonstration and Evaluation Virtual Machine (SP1)&lt;/a&gt;.&amp;nbsp;Please note that there are no public folders available on the Exchange Server available in this&amp;nbsp;package, so you have to &lt;a title="enable the public folder database" href="http://technet.microsoft.com/en-us/library/dd335208.aspx"&gt;enable the public folder database&lt;/a&gt; and &lt;a href="http://technet.microsoft.com/en-us/library/bb691104.aspx"&gt;create some public folders&lt;/a&gt; by yourself.&lt;/p&gt;
&lt;p&gt;First, create the content source:&lt;/p&gt;
&lt;p&gt;1. Go into your FAST Content SSA (FASTContent) and create a new content source.&lt;/p&gt;
&lt;p&gt;2. Give your content source a name, and choose "Exchange Public Folders".&lt;/p&gt;
&lt;p&gt;3. Type the start address; this is the tricky part. To find it, go to your OWA, in my case &lt;a href="https://demo2010b/exchange"&gt;https://demo2010b/exchange&lt;/a&gt;. Click on Public Folders in the left bottom corner. In the new view right click on Public Folders and choose "Open in New Window". The URL you get is your start URL. It is ugly, mine is: &lt;a href="https://demo2010b/owa/?ae=Folder&amp;amp;t=IPF.Note&amp;amp;id=PSF.LgAAAAAaRHOQqmYRzZvIAKoAL8RaAwAryKKxImnhRaK28blMCPQ0AAAAAAABAAAB&amp;amp;pspid=_1317728045392_959158536"&gt;https://demo2010b/owa/?ae=Folder&amp;amp;t=IPF.Note&amp;amp;id=PSF.LgAAAAAaRHOQqmYRzZvIAKoAL8RaAwAryKKxImnhRaK28blMCPQ0AAAAAAABAAAB&amp;amp;pspid=_1317728045392_959158536&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85/7444.exchangecontentsource.png"&gt;&lt;img border="0" alt="" src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-85/7444.exchangecontentsource.png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Second, create a crawl rule to make sure the crawler authenticates correctly.&lt;/p&gt;
&lt;p&gt;1. Go into Crawl Rules in your Content SSA.&lt;/p&gt;
&lt;p&gt;2. Click "New Crawl Rule"&lt;/p&gt;
&lt;p&gt;3. Input the PATH of your OWA, in by case &lt;a href="https://demo2010b/"&gt;https://demo2010b/&lt;/a&gt;*&lt;/p&gt;
&lt;p&gt;4. Choose "Include all items in this path"&lt;/p&gt;
&lt;p&gt;5. Specify authentication; in my case I used the default content access account.&lt;/p&gt;
&lt;p&gt;Then start crawling, enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10219702" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/murads/archive/tags/fs4sp/">fs4sp</category><category domain="http://blogs.msdn.com/b/murads/archive/tags/fastsearch+for+sharepoint/">fastsearch for sharepoint</category><category domain="http://blogs.msdn.com/b/murads/archive/tags/exchange+2010/">exchange 2010</category></item></channel></rss>