<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss'><id>tag:blogger.com,1999:blog-5787751540548761056</id><updated>2010-03-10T08:43:44.156Z</updated><title type='text'>Muhimbi's SharePoint Blog</title><subtitle type='html'>Muhimbi Ltd is a provider of shrink wrapped solutions for the SharePoint market. All our products, such as PDF Converters and Audit Log management tools, are designed for both MOSS and WSS 3 and are available in a number of different languages.</subtitle><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/default.html'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default?start-index=26&amp;max-results=25'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.muhimbi.com/blog/feed.xml'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>67</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-3375351768546406563</id><published>2010-02-24T15:53:00.001Z</published><updated>2010-02-24T16:27:36.355Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Products'/><category scheme='http://www.blogger.com/atom/ns#' term='PDF Converter'/><category scheme='http://www.blogger.com/atom/ns#' term='Articles'/><title type='text'>Using Muhimbi’s PDF Converter with Office 2010</title><content type='html'>&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="Office2010" border="0" alt="Office2010" align="right" src="http://lh5.ggpht.com/_IgJp5HQ80aU/S4VLij5tQiI/AAAAAAAAAM8/mfmQ0u6GRVo/Office2010%5B5%5D.png?imgmax=800" width="144" height="139"&gt;Earlier today &lt;a href="http://www.muhimbi.com/blog/2010/02/pdf-converter-for-sharepoint-32-with.html"&gt;we released a new version&lt;/a&gt; of our popular PDF Converter for SharePoint. One of the key changes in this version is that it fully supports Office 2010 file formats, including all new formatting features such as &lt;a href="http://blogs.msdn.com/excel/archive/2009/07/17/sparklines-in-excel.aspx"&gt;Excel 2010 Sparklines&lt;/a&gt;. &lt;/p&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2010/02/using-muhimbis-pdf-converter-with.html';&lt;/script&gt;&lt;span style="margin-top: 3px; float: left; margin-right: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;Full installation details are provided in &lt;em&gt;Appendix – Office 2010 Installation&lt;/em&gt; of the &lt;a href="http://www.muhimbi.com/support/documentation/PDF-Converter-for-SharePoint/Administration-Guide.aspx"&gt;Administration Guide&lt;/a&gt;, however one detail is so essential that we feel we have to repeat it in this blog post. After all, who reads boring documentation anyway?&lt;/p&gt; &lt;p&gt;The single most important thing to take away from this post is that no matter what CPU architecture you deploy the PDF Converter on, if you plan to use Office 2010 to carry out the conversions then you should &lt;strong&gt;&lt;em&gt;&lt;u&gt;&lt;font color="#ff0000"&gt;always install the 32 bit version of Office 2010&lt;/font&gt;&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt;. &lt;/p&gt; &lt;p&gt;Even though the Muhimbi PDF Converter for SharePoint is a hybrid 32 / 64 bit application, the 64 bit version of Office will not work in combination with our software. Even if it did, it would provide little to no benefit.&lt;/p&gt; &lt;p&gt;For more details about the differences between the 32 and 64 bit versions of Office, including Microsoft’s recommendation to run the 32-bit version of Office 2010 on 64 bit hardware, &lt;a href="http://blogs.technet.com/office2010/archive/2010/02/23/understanding-64-bit-office.aspx"&gt;read this article on Microsoft’s Office 2010 blog&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&lt;font color="white"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-3375351768546406563?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/3375351768546406563/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2010/02/using-muhimbis-pdf-converter-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/3375351768546406563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/3375351768546406563'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2010/02/using-muhimbis-pdf-converter-with.html' title='Using Muhimbi’s PDF Converter with Office 2010'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-8966691262266843281</id><published>2010-02-24T14:29:00.001Z</published><updated>2010-02-24T15:15:16.497Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPP'/><category scheme='http://www.blogger.com/atom/ns#' term='Products'/><category scheme='http://www.blogger.com/atom/ns#' term='PDF Converter'/><category scheme='http://www.blogger.com/atom/ns#' term='Workflow'/><category scheme='http://www.blogger.com/atom/ns#' term='Articles'/><title type='text'>Use SharePoint Workflows to inject JavaScript into PDFs and print the ‘open date’</title><content type='html'>&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="Calendar" border="0" alt="Calendar" align="right" src="http://lh6.ggpht.com/_IgJp5HQ80aU/S4U3rb2HRXI/AAAAAAAAAMw/kj5vRCjYHmw/Calendar%5B5%5D.jpg?imgmax=800" width="140" height="136"&gt; Ah, those pesky customers of ours, always looking for some &lt;em&gt;niche functionality&lt;/em&gt; that is impossible to include in a generic product. However, using the &lt;a href="http://www.muhimbi.com/Products/Workflow-Power-Pack-for-SharePoint/summary.aspx"&gt;Workflow Power Pack for SharePoint&lt;/a&gt; we can achieve almost anything we can think of…..almost. &lt;/p&gt; &lt;p&gt;Previously I described &lt;a href="http://www.muhimbi.com/blog/2010/01/configure-pdf-security-from-sharepoint.html"&gt;how to configure PDF Security settings from a SharePoint workflow&lt;/a&gt; and &lt;a href="http://www.muhimbi.com/blog/2010/01/adding-watermark-to-pdf-file-from.html"&gt;how to automatically watermark PDF files from a workflow&lt;/a&gt;.&amp;nbsp; This time I’ll show how to add JavaScript to any PDF file to automatically print the current date (the date the PDF was opened) on every page. In essence this adds a &lt;em&gt;print date &lt;/em&gt;without modifying the PDF file every day to include the current date.&lt;/p&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2010/02/use-sharepoint-workflow-to-inject.html';&lt;/script&gt;&lt;span style="margin-top: 3px; float: left; margin-right: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;A quick introduction for those not familiar with the product: &lt;em&gt;The Muhimbi Workflow Power Pack for SharePoint allows custom C# or VB.NET code to be embedded in SharePoint Designer Workflows without the need to resort to complex Visual Studio based workflows, the development of bespoke Workflow Activities or long development cycles.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;The solution presented below executes a workflow whenever a PDF file is added or updated. It iterates over all pages and inserts a form field on each page. Some client side JavaScript is then added to the PDF file that iterates over all newly added fields to insert the current date every time the PDF file is opened.&lt;/p&gt; &lt;p&gt;As the code is well documented it is easy to make further changes and customisations, e.g. change the formatting of the date or position of the label. Note that this has only been tested with a recent version of Adobe Acrobat reader. If you use a different PDF viewer your mileage may vary.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;br&gt;Create the workflow as follows:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;&lt;a href="http://www.muhimbi.com/Products/Workflow-Power-Pack-for-SharePoint.aspx"&gt;Download and install the Muhimbi Workflow Power Pack for SharePoint&lt;/a&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;a href="http://www.muhimbi.com/Products/PDF-Converter-for-SharePoint.aspx"&gt;Download and install the Muhimbi PDF Converter for SharePoint&lt;/a&gt;. &lt;br&gt;&lt;strong&gt;&lt;em&gt;&lt;font color="#ff0000"&gt;Note that you need version 3.2.0.20 or newer, older versions do not allow JavaScript to be inserted&lt;/font&gt;&lt;/em&gt;&lt;/strong&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;a href="http://www.muhimbi.com/Images---Files/WorkflowPowerPack/Muhimbi-Workflow-JavaScript-Watermarking.aspx"&gt;Download this article’s source code&lt;/a&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;We need to be able to access functionality in the &lt;em&gt;Muhimbi.SharePoint.DocumentConverter.PDF&lt;/em&gt; and &lt;em&gt;System.Drawing&lt;/em&gt; assemblies. Add these references to the relevant Web Application using the &lt;i&gt;Workflow Power Pack Central Administration screens&lt;/i&gt; as described in the &lt;a href="http://www.muhimbi.com/support/documentation/Workflow-Power-Pack/Administration-Guide.aspx"&gt;Administration Guide&lt;/a&gt;. Make sure to place each reference on a new line.&lt;br&gt;&amp;nbsp;&amp;nbsp; &lt;li&gt;Make sure you have the appropriate privileges to create workflows on a site collection.&lt;br&gt;&amp;nbsp; &lt;li&gt;Create a new workflow using SharePoint Designer.&lt;br&gt;&amp;nbsp; &lt;li&gt;On the Workflow definition screen associate the workflow with the &lt;em&gt;Shared Documents&lt;/em&gt; library, tick the boxes next to both ‘&lt;em&gt;Automatically start….&lt;/em&gt;’ options and proceed to the next screen.&lt;br&gt;&amp;nbsp; &lt;li&gt;We only want to act on files of type PDF. Although we could have put this validation in the code, in this example we use a workflow condition for it so add a &lt;em&gt;Compare Any Data Source&lt;/em&gt; condition and:&lt;br&gt;&amp;nbsp;&lt;br&gt;a.&amp;nbsp; Click on the first &lt;em&gt;value&lt;/em&gt; followed by the &lt;em&gt;display data binding&lt;/em&gt; (fx) button. &lt;br&gt;b.&amp;nbsp; Select &lt;em&gt;Current Item&lt;/em&gt; as the Source and select &lt;em&gt;File Type&lt;/em&gt; in the Field. Click the OK button to continue. &lt;br&gt;d.&amp;nbsp; Click on the second &lt;em&gt;value&lt;/em&gt; and enter &lt;em&gt;pdf&lt;/em&gt;. &lt;br&gt;&amp;nbsp; &lt;li&gt;Click the &lt;i&gt;Actions&lt;/i&gt; button and insert the &lt;em&gt;Execute Custom Code &lt;/em&gt;action&lt;em&gt;.&lt;br&gt;&amp;nbsp; &lt;/em&gt; &lt;li&gt;Optionally click &lt;u&gt;parameter 1&lt;/u&gt; and enter a relative or absolute destination path. Leave the parameter empty to save the modified file on top of the existing PDF file. For details about how paths are handled, see &lt;a href="http://www.muhimbi.com/blog/2009/11/automatically-convert-files-to-pdf.html"&gt;this post&lt;/a&gt; and search for the words ‘this url’. &lt;br&gt;&amp;nbsp; &lt;li&gt;Insert the C# based code embedded in step #3’s download (also listed below) by clicking &lt;u&gt;this code&lt;/u&gt;.&lt;br&gt;&amp;nbsp; &lt;div style="padding-bottom: 6px; padding-left: 6px; padding-right: 6px; font-family: consolas; background: black; color: white; font-size: 8pt; font-weight: bold; padding-top: 6px"&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;/*********************************************************************************************&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Muhimbi PDF Converter - JavaScript Watermarking&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Copyright 2010, Muhimbi Ltd - www.muhimbi.com - All rights reserved&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; The following code shows a simple way of adding JavaScript to existing PDF Files. It adds &lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; the current date to each page in the document in order to simulate a 'print date' that is&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; always up to date without the need to modify the PDF file. The code is automatically executed &lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; when the document is opened in the Adobe Acrobat Viewer.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; Error and permission checking as well as other minor features have been omitted for the sake &lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; of brevity and clarity.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; Ideally PDF Conversion, applying security and watermarking is executed in the same step, see &lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; http://www.muhimbi.com/blog/2010/01/configure-pdf-security-from-sharepoint.html&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; This code requires Muhimbi’s PDF Converter and Workflow Power Pack to be installed.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;*********************************************************************************************/&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; System.Drawing;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; System.IO;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; Syncfusion.Pdf;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; Syncfusion.Pdf.Parsing;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; Syncfusion.Pdf.Graphics;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; Syncfusion.Pdf.Interactive;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; Muhimbi.SharePoint.DocumentConverter.PDF;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SPFile spSourceDocument = MyWorkflow.Item.File;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; destinationFileName = spSourceDocument.Name;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; destinationFolderName = MyWorkflow.Parameter1 &lt;span style="color: #cc7832"&gt;as&lt;/span&gt; &lt;span style="color: #cc7832"&gt;string&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Load the document&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;PdfLoadedDocument sourceDocument = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; PdfLoadedDocument(spSourceDocument.OpenBinary());&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;PdfDocument destinationDocument = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; PdfDocument();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Copy all pages from the source document into the destination document &lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** so we can add JavaScript actions.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;destinationDocument.ImportPageRange(sourceDocument, &lt;span style="color: #6897bb"&gt;0&lt;/span&gt;, sourceDocument.Pages.Count - &lt;span style="color: #6897bb"&gt;1&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;sourceDocument.Dispose();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Iterate over all pages and add a form element&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;for&lt;/span&gt; (&lt;span style="color: #cc7832"&gt;int&lt;/span&gt; i = &lt;span style="color: #6897bb"&gt;0&lt;/span&gt;; i &amp;lt; destinationDocument.Pages.Count; i++)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PdfPage destinationPage = destinationDocument.Pages[i];&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Create a new field using a unique name&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PdfTextBoxField field = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; PdfTextBoxField(destinationPage, &lt;span style="color: #a5c25c"&gt;"_M_PrintDateField_"&lt;/span&gt; + i);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Center the field&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;const&lt;/span&gt; &lt;span style="color: #cc7832"&gt;int&lt;/span&gt; BOX_WIDTH = &lt;span style="color: #6897bb"&gt;200&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;int&lt;/span&gt; boxLeft = (&lt;span style="color: #cc7832"&gt;int&lt;/span&gt;)((destinationPage.Size.Width - BOX_WIDTH) / &lt;span style="color: #6897bb"&gt;2&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; field.Bounds = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; RectangleF(boxLeft, &lt;span style="color: #6897bb"&gt;20&lt;/span&gt;, BOX_WIDTH, &lt;span style="color: #6897bb"&gt;20&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Format the field&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PdfFont font = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; PdfStandardFont(PdfFontFamily.Helvetica, &lt;span style="color: #6897bb"&gt;12f&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; field.Font = font;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; field.BorderColor = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; PdfColor(Color.White);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; field.BackColor = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; PdfColor(Color.White);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; field.ReadOnly = &lt;span style="color: #cc7832"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; field.TextAlignment = PdfTextAlignment.Center;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; destinationDocument.Form.Fields.Add(field);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Create a client side script that iterates over all fields and populates the date&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; jscript = &lt;span style="color: #eb6767; font-weight: normal"&gt;@"&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #eb6767; font-weight: normal"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var pages = "&lt;/span&gt; + destinationDocument.Pages.Count + &lt;span style="color: #eb6767; font-weight: normal"&gt;@";&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #eb6767; font-weight: normal"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var today = util.printd('dd-mm-yyyy', new Date());&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #eb6767; font-weight: normal"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(var i=0; i&amp;lt;pages; i++)&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #eb6767; font-weight: normal"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #eb6767; font-weight: normal"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var field = this.getField('_M_PrintDateField_' + i);&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #eb6767; font-weight: normal"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; field.value = 'Today is: ' + today;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #eb6767; font-weight: normal"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #eb6767; font-weight: normal"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Attach the script to the Document Open event.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;PdfJavaScriptAction jsAction = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; PdfJavaScriptAction(jscript);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;destinationDocument.Actions.AfterOpen = jsAction;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Construct the path and file to write the watermarked PDF file to.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;if&lt;/span&gt; (&lt;span style="color: #cc7832"&gt;string&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.IsNullOrEmpty(destinationFolderName) == &lt;/span&gt;&lt;span style="color: #cc7832"&gt;true&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; destinationFolderName = spSourceDocument.ParentFolder.Url;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SPFolder destinationFolder = Utility.GetSPFolder(destinationFolderName, MyWorkflow.Web);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; destinationFilePath = &lt;span style="color: #cc7832"&gt;string&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.Format(&lt;/span&gt;&lt;span style="color: #a5c25c"&gt;"{0}/{1}"&lt;/span&gt;, destinationFolder.Url,&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; destinationFileName);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SPWeb destinationWeb = destinationFolder.ParentWeb;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SPFile spDestinationFile = destinationWeb.GetFile(destinationFilePath);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** If a document library requires manual checkout and the file is not checked out, then &lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** check the file out before uploading.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;if&lt;/span&gt; (spDestinationFile.Exists &amp;amp;&amp;amp; spDestinationFile.Item.ParentList.ForceCheckout &amp;amp;&amp;amp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; spDestinationFile.CheckOutStatus == SPFile.SPCheckOutStatus.None)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; spDestinationFile.CheckOut();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Add the file to the site including the meta data&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; (MemoryStream watermarkedFile = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; MemoryStream())&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; destinationDocument.Save(watermarkedFile);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; spDestinationFile = destinationWeb.Files.Add(destinationFilePath, watermarkedFile,&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; spSourceDocument.Item.Properties, &lt;span style="color: #cc7832"&gt;true&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Check the file back in if this script was responsible for checking it out.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;if&lt;/span&gt; (spDestinationFile.Item.ParentList.ForceCheckout == &lt;span style="color: #cc7832"&gt;true&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; spDestinationFile.CheckIn(&lt;span style="color: #a5c25c"&gt;"Auto check-in after PDF watermarking."&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;/div&gt;&amp;nbsp; &lt;li&gt;Click the &lt;i&gt;Actions&lt;/i&gt; button, select &lt;i&gt;Log to History List&lt;/i&gt;, click &lt;i&gt;&lt;u&gt;this message&lt;/u&gt;&lt;/i&gt; and enter &lt;em&gt;File watermarked&lt;/em&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;Close the Workflow Designer.&lt;br&gt;&amp;nbsp; &lt;li&gt;Update an existing PDF or add a new PDF file to your library to trigger the workflow and apply the JavaScript. &lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&amp;nbsp;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="WaterMarkScript" border="0" alt="WaterMarkScript" src="http://lh6.ggpht.com/_IgJp5HQ80aU/S4U3rqimxbI/AAAAAAAAAM0/mWN5dWyR4UA/WaterMarkScript%5B4%5D.jpg?imgmax=800" width="575" height="304"&gt;&amp;nbsp;&lt;br&gt;Naturally this is just a simple example. Feel free to play around with the code, change which parameters are passed into the workflow, or add different JavaScript. Note that you may want to add a check to the code to check if the JavaScript / fields have previously been added, otherwise duplicate form fields may be added every time the PDF is updated. &lt;/p&gt;
&lt;p&gt;Adobe’s JavaScript for Acrobat reference &lt;a href="http://www.adobe.com/devnet/acrobat/javascript.html"&gt;can be found here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;font color="white"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-8966691262266843281?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/8966691262266843281/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2010/02/use-sharepoint-workflow-to-inject.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/8966691262266843281'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/8966691262266843281'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2010/02/use-sharepoint-workflow-to-inject.html' title='Use SharePoint Workflows to inject JavaScript into PDFs and print the ‘open date’'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-1318846321424253964</id><published>2010-02-24T11:02:00.001Z</published><updated>2010-02-24T15:32:50.541Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='News'/><category scheme='http://www.blogger.com/atom/ns#' term='Products'/><category scheme='http://www.blogger.com/atom/ns#' term='PDF Converter'/><title type='text'>PDF Converter for SharePoint 3.2 – With new support for Office 2010</title><content type='html'>&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="PDFConverterBox" border="0" alt="PDFConverterBox" align="right" src="http://lh6.ggpht.com/_IgJp5HQ80aU/S4UHT1V5foI/AAAAAAAAAMo/yy_Vl9sHlgw/PDFConverterBox%5B5%5D.jpg?imgmax=800" width="200" height="183"&gt;We are very excited to announce the new version of the &lt;a href="http://www.muhimbi.com/Products/PDF-Converter-for-SharePoint/Summary.aspx"&gt;Muhimbi PDF Converter for SharePoint&lt;/a&gt;. The main change in this version is support for Office 2010 based converters and file formats. &lt;/p&gt; &lt;p&gt;We are quite surprised by the number of customers asking for Office 2010 support, especially considering that at the time of writing it is still in beta. On the other hand, it appears to be very stable and particularly the improvements in converting InfoPath forms to PDF format make it worth considering.&lt;/p&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2010/02/pdf-converter-for-sharepoint-32-with.html';&lt;/script&gt;&lt;span style="margin-top: 3px; float: left; margin-right: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;&lt;em&gt;For those not familiar with the product, the PDF Converter for SharePoint is a lightweight solution that allows end-users to convert common document types to PDF format from within SharePoint without the need to install any client side software or Adobe Acrobat. It integrates at a deep level with SharePoint and leverages facilities such as the Audit log, localisation, security and tracing. It runs on both WSS 3 as well as MOSS and is available in English, German, Dutch, French and Japanese. For detailed information check out the &lt;/em&gt;&lt;a href="http://www.muhimbi.com/Products/PDF-Converter-for-SharePoint.aspx"&gt;&lt;em&gt;product page&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.&lt;/em&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="workflow2" border="0" alt="workflow2" src="http://lh3.ggpht.com/_IgJp5HQ80aU/S4UHUb1EatI/AAAAAAAAAMs/sx9ZX_kKl9c/workflow2%5B5%5D.jpg?imgmax=800" width="680" height="193"&gt;  &lt;div style="position: relative; text-align: center; font-size: 8pt; top: -20px"&gt;&lt;i&gt;Convert files using the User Interface or an automated Workflow&lt;/i&gt;&lt;/div&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;The main changes in version 3.2 are as follows:&lt;/p&gt; &lt;table border="0" cellspacing="0" cellpadding="2" width="700"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" width="31"&gt;&lt;font size="2"&gt;778&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" width="667"&gt;&lt;font size="2"&gt;New: Support for Office 2010 has been added.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top"&gt;&lt;font size="2"&gt;768&lt;/font&gt;&lt;/td&gt; &lt;td valign="top"&gt;&lt;font size="2"&gt;New: For InfoPath conversions, disabling of external data sources and embedded code has been made optional.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;br&gt;For more information check out the following resources:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://www.muhimbi.com/Products/PDF-Converter-for-SharePoint.aspx"&gt;Product Page&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/faqs.aspx"&gt;FAQ&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/documentation/PDF-Converter-for-SharePoint/Release-Notes.aspx"&gt;Release Notes&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/documentation/PDF-Converter-for-SharePoint/Administration-Guide.aspx"&gt;Administration Guide&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/documentation/PDF-Converter-for-SharePoint/User-Guide.aspx"&gt;User Guide&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/documentation/PDF-Converter-for-SharePoint/Screenshots.aspx"&gt;Screenshots&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/forum.aspx"&gt;Message Board&lt;/a&gt;. &lt;/li&gt;&lt;/ul&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2010/02/pdf-converter-for-sharepoint-32-with.html';&lt;/script&gt;&lt;span style="margin-top: 11px; float: right; margin-left: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;&amp;nbsp;&lt;br&gt;As always, feel free to &lt;a href="http://www.muhimbi.com/contact.aspx"&gt;contact us using Twitter, our Blog, regular email&lt;/a&gt; or &lt;a href="http://eepurl.com/b6A7"&gt;subscribe to our newsletter&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p align="center"&gt;&lt;a href="http://www.muhimbi.com/Products/PDF-Converter-for-SharePoint/Free-Trial.aspx"&gt;Download your free trial here&lt;/a&gt; (4MB). &lt;br&gt;&lt;font color="#ffffff"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-1318846321424253964?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/1318846321424253964/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2010/02/pdf-converter-for-sharepoint-32-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/1318846321424253964'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/1318846321424253964'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2010/02/pdf-converter-for-sharepoint-32-with.html' title='PDF Converter for SharePoint 3.2 – With new support for Office 2010'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-2136951552654082091</id><published>2010-02-22T11:50:00.001Z</published><updated>2010-02-22T11:52:02.175Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='News'/><category scheme='http://www.blogger.com/atom/ns#' term='SP2010'/><category scheme='http://www.blogger.com/atom/ns#' term='Articles'/><title type='text'>SharePoint 2010 Beta – No longer possible to keep indexes on-line while rebuilding them</title><content type='html'>&lt;p&gt;Just a quick note to make sure that anyone typing this error message into a search engine will find this post.&lt;/p&gt; &lt;p&gt;Due to a change in the SharePoint 2010 &lt;em&gt;AllDocVersions&lt;/em&gt; table it is no longer possible to rebuild indexes as part of a SQL 2008 maintenance plan and keep the indexes on-line at the same time.&lt;/p&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2010/02/sharepoint-2010-beta-no-longer-possible.html';&lt;/script&gt;&lt;span style="margin-top: 3px; float: left; margin-right: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;The reason behind this is that the &lt;em&gt;MetaInfo&lt;/em&gt; field is no longer of type &lt;em&gt;Image. &lt;/em&gt;It is now of type &lt;em&gt;tCompressedBinary:varbinary(MAX)&lt;/em&gt;.&lt;/p&gt; &lt;p&gt;If you get the error listed below then make sure you open the &lt;em&gt;Rebuild Index Task&lt;/em&gt; in your SQL Maintenance plan and disable the ‘Keep index online while reindexing’ option.  &lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Rebuild-Indexes" border="0" alt="Rebuild-Indexes" src="http://lh5.ggpht.com/_IgJp5HQ80aU/S4Jve5xj-QI/AAAAAAAAAMg/-cdqhFUS8MA/Rebuild-Indexes%5B5%5D.png?imgmax=800" width="482" height="453"&gt;  &lt;p&gt;&amp;nbsp; &lt;p&gt;If you don’t then you’ll get the following error:  &lt;p&gt;&lt;em&gt;Executing the query "ALTER INDEX [AllDocVersions_PK] ON [dbo].[AllDocVe..." failed with the following error: "An online operation cannot be performed for index 'AllDocVersions_PK' because the index contains column 'MetaInfo' of data type text, ntext, image, varchar(max), nvarchar(max), varbinary(max), xml, or large CLR type. For a non-clustered index, the column could be an include column of the index. For a clustered index, the column could be any column of the table. If DROP_EXISTING is used, the column could be part of a new or old index. The operation must be performed offline.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. &lt;/em&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;If you use one of the default maintenance plans then this error happens before the &lt;em&gt;Backup&lt;/em&gt; step. As a result your databases will not be backed up.&lt;/p&gt; &lt;p&gt;&lt;font color="white"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-2136951552654082091?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/2136951552654082091/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2010/02/sharepoint-2010-beta-no-longer-possible.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/2136951552654082091'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/2136951552654082091'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2010/02/sharepoint-2010-beta-no-longer-possible.html' title='SharePoint 2010 Beta – No longer possible to keep indexes on-line while rebuilding them'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-3274278634538742518</id><published>2010-02-18T13:22:00.001Z</published><updated>2010-02-18T13:26:39.378Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='MuSH'/><category scheme='http://www.blogger.com/atom/ns#' term='News'/><category scheme='http://www.blogger.com/atom/ns#' term='Products'/><category scheme='http://www.blogger.com/atom/ns#' term='Workflow'/><category scheme='http://www.blogger.com/atom/ns#' term='Articles'/><title type='text'>Create Shortened (‘TinyURL’) links from your SharePoint Workflow – Part 2</title><content type='html'>&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="workflow" border="0" alt="workflow" align="right" src="http://lh5.ggpht.com/_IgJp5HQ80aU/S30-99tAPpI/AAAAAAAAAMY/ATAxssCPPBI/workflow%5B5%5D.jpg?imgmax=800" width="153" height="141"&gt; Not too long ago we wrote about &lt;a href="http://www.muhimbi.com/blog/2009/12/create-shortened-tinyurl-links-from.html"&gt;how to create a Short URL from a SharePoint workflow&lt;/a&gt; using the Muhimbi URL Shortener (MuSH) in combination with our Workflow Power Pack. The response from our customers has been so positive that we decided to ship a Workflow Action with the &lt;a href="http://www.muhimbi.com/blog/2010/02/new-release-of-mush-workflow-enabled.html"&gt;new version of MuSH&lt;/a&gt;.&lt;/p&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2010/02/create-shortened-tinyurl-links-from.html';&lt;/script&gt;&lt;span style="margin-top: 3px; float: left; margin-right: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;&lt;em&gt;For those not familiar with the product&lt;/em&gt;&lt;em&gt;, the Muhimbi URL Shortener for SharePoint, aka MuSH, can be used to shorten URLs for typical web applications and SharePoint in particular. It integrates tightly with both WSS and MOSS and allows short URLs to be created directly from a list item’s context menu, workflows and web services. For details &lt;a href="http://www.muhimbi.com/blog/2009/06/reducing-size-of-urls-using-mush.html"&gt;see the original product announcement&lt;/a&gt;.&lt;/em&gt; &lt;/p&gt; &lt;p&gt;Creating short URLs from a workflow can be very useful. For example creating a short URL named after data in an InfoPath form or create a short URL for a deeply nested folder. In the example below we create a short URL that always points to the latest entry in the announcement list. Not sure if this is useful, but it illustrates the power of this facility.&lt;/p&gt; &lt;p&gt;Create the workflow as follows: &lt;/p&gt; &lt;ol&gt; &lt;li&gt;&lt;a href="http://www.muhimbi.com/Products/SharePoint-URL-Shortener/Summary.aspx"&gt;Download and install the Muhimbi URL Shortener for SharePoint&lt;/a&gt;.&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;li&gt;Make sure you have the appropriate privileges to create workflows on a site collection.&lt;br&gt;&amp;nbsp; &lt;li&gt;Create a new workflow using SharePoint Designer.&lt;br&gt;&amp;nbsp; &lt;li&gt;On the Workflow Definition screen associate the workflow with the &lt;em&gt;Announcements&lt;/em&gt; list, tick the box next to ‘&lt;em&gt;Automatically start this workflow when a new item is created&lt;/em&gt;’ and proceed to the next screen.&lt;br&gt;&amp;nbsp; &lt;li&gt;From the &lt;em&gt;Actions&lt;/em&gt; Menu select &lt;em&gt;Create Short URL&lt;/em&gt;, you may need to click &lt;em&gt;More Actions&lt;/em&gt; first.&lt;br&gt;&amp;nbsp; &lt;li&gt;The following Workflow Sentence is inserted:&lt;br&gt;&lt;br&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image10" border="0" alt="image10" src="http://lh5.ggpht.com/_IgJp5HQ80aU/S30--YvGryI/AAAAAAAAAMc/AQggyAZKcco/image10%5B5%5D.png?imgmax=800" width="523" height="59"&gt;&amp;nbsp;&amp;nbsp; &lt;li&gt;To auto generate the short URL, leave the &lt;u&gt;optional short name&lt;/u&gt; empty, but in our case we always want to give it the same name, so enter &lt;em&gt;Announce&lt;/em&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;Click &lt;u&gt;this ID / address&lt;/u&gt;, click the &lt;em&gt;Workflow Lookup button&lt;/em&gt; and select &lt;em&gt;Current Item&lt;/em&gt; as the &lt;em&gt;Source&lt;/em&gt; and &lt;em&gt;ID&lt;/em&gt; as the &lt;em&gt;field&lt;/em&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;Click &lt;u&gt;Document / Display Form&lt;/u&gt; and select &lt;em&gt;Document&lt;/em&gt; (when used in a Document Library) or &lt;em&gt;Display Form&lt;/em&gt; showing the item’s properties. As we are not dealing with a Document Library, it doesn’t matter what is selected.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;u&gt;Click Overwrite / Return null&lt;/u&gt; and select the &lt;em&gt;Overwrite&lt;/em&gt; as we always want to write the latest announcement using the same short name. (Return Null will return null in the output variable, which can then be tested for and action can be taken accordingly.)&lt;br&gt;&amp;nbsp; &lt;li&gt;Click &lt;u&gt;Variable: this variable&lt;/u&gt; and specify the variable the Short URL will be stored in. In this example name it &lt;em&gt;shortURL&lt;/em&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;Add a &lt;em&gt;Log To History List&lt;/em&gt; Action and specify the name of the workflow variable the Short URL has been stored in using the Workflow Lookup dialog box.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;Close the workflow and create a new Announcement. When the workflow has finished, click the &lt;em&gt;completed&lt;/em&gt; link to see the output. Click the generated URL to link to the latest announcement.&lt;/p&gt; &lt;p&gt;Create another Announcement, the Short URL should now link to the latest announcement.&lt;/p&gt; &lt;p&gt;&lt;font color="white"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-3274278634538742518?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/3274278634538742518/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2010/02/create-shortened-tinyurl-links-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/3274278634538742518'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/3274278634538742518'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2010/02/create-shortened-tinyurl-links-from.html' title='Create Shortened (‘TinyURL’) links from your SharePoint Workflow – Part 2'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-2927225777027586904</id><published>2010-02-16T14:30:00.001Z</published><updated>2010-02-16T14:34:11.715Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='MuSH'/><category scheme='http://www.blogger.com/atom/ns#' term='News'/><category scheme='http://www.blogger.com/atom/ns#' term='Products'/><category scheme='http://www.blogger.com/atom/ns#' term='Workflow'/><title type='text'>New release of MuSH – Workflow Enabled ‘TinyURL’ for SharePoint v2</title><content type='html'>&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="MushBox" border="0" alt="MushBox" align="right" src="http://lh3.ggpht.com/_IgJp5HQ80aU/S3qr7jlupFI/AAAAAAAAAMQ/Hmbtn9z3ieA/MushBox%5B5%5D.jpg?imgmax=800" width="200" height="183"&gt;Live never stops at Muhimbi. It has only been 7 days since we &lt;a href="http://www.muhimbi.com/blog/2010/02/workflow-power-pack-11-embed-cvb-code.html"&gt;announced a new version of the Workflow Power Pack&lt;/a&gt; and here we are again with the brand new ‘&lt;em&gt;2.0&lt;/em&gt;’ version of our &lt;a href="http://www.muhimbi.com/Products/SharePoint-URL-Shortener/summary.aspx"&gt;URL Shortener for SharePoint&lt;/a&gt;. This version adds support for generating short URLs from workflows, manually specifying short URL names, new languages as well as some other new features and fixes. For full details see the table below.&lt;/p&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2010/02/new-release-of-mush-workflow-enabled.html';&lt;/script&gt;&lt;span style="margin-top: 3px; float: left; margin-right: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;&lt;em&gt;For those not familiar with the product&lt;/em&gt;&lt;em&gt;, the Muhimbi URL Shortener for SharePoint, aka MuSH, can be used to shorten URLs for typical web applications and SharePoint in particular. It integrates tightly with both WSS and MOSS and allows short URLs to be created directly from a list item’s context menu, workflows and web services. For details &lt;a href="http://www.muhimbi.com/blog/2009/06/reducing-size-of-urls-using-mush.html"&gt;see the original announcement&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;The main changes and improvements are as follows:&lt;/p&gt; &lt;table border="0" cellspacing="0" cellpadding="2" width="670"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" width="31"&gt;&lt;font size="2"&gt;562&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" width="637"&gt;&lt;font size="2"&gt;New: Allow users to specify their own Short URL.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="31"&gt;&lt;font size="2"&gt;556&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" width="637"&gt;&lt;font size="2"&gt;New: Allow users to specify if they want the short URL to point to the Document rather than the Display Form.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="31"&gt;&lt;font size="2"&gt;760&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" width="637"&gt;&lt;font size="2"&gt;New: Allow the URL Shortener to be called from any page using SharePoint’s Personal Action’s menu.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="31"&gt;&lt;font size="2"&gt;561&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" width="637"&gt;&lt;font size="2"&gt;New: Allow the URL Shortener to be invoked from a SharePoint Designer Workflow.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="31"&gt;&lt;font size="2"&gt;735&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" width="637"&gt;&lt;font size="2"&gt;Fixed: Make sure that the same Short URL is returned if a long URL has been shortened before.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="31"&gt;&lt;font size="2"&gt;655&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" width="637"&gt;&lt;font size="2"&gt;New: Add Support for Simplified Chinese in the user interface.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&lt;br&gt;&amp;nbsp;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="Workflow-690" border="0" alt="Workflow-690" src="http://lh6.ggpht.com/_IgJp5HQ80aU/S3qr7_5QHNI/AAAAAAAAAMU/KZH2VEL0SMI/Workflow-690%5B7%5D.png?imgmax=800" width="674" height="289"&gt; &lt;/p&gt; &lt;p&gt;For more information check out the:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://www.muhimbi.com/Products/SharePoint-URL-Shortener.aspx"&gt;Product Page&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/documentation/URL-Shortener/Release-Notes.aspx"&gt;Release Notes&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/documentation/URL-Shortener/Administration-Guide.aspx"&gt;User &amp;amp; Administration Guide&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/documentation/URL-Shortener/Screenshots.aspx"&gt;More Screenshots&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/forum.aspx?ForumID=4"&gt;Message Board&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/labels/MuSH.html"&gt;All MuSH related Blog Postings&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2010/02/new-release-of-mush-workflow-enabled.html';&lt;/script&gt;&lt;span style="float: right; margin-left: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;As always, feel free to &lt;a href="http://www.muhimbi.com/contact.aspx"&gt;contact us using Twitter, our Blog or regular email&lt;/a&gt; or &lt;a href="http://eepurl.com/b6A7"&gt;subscribe to our newsletter&lt;/a&gt;.&lt;/p&gt; &lt;p align="center"&gt;&lt;a href="http://www.muhimbi.com/Products/SharePoint-URL-Shortener/Free-Trial.aspx"&gt;Download your free trial here&lt;/a&gt; (1MB).&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-2927225777027586904?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/2927225777027586904/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2010/02/new-release-of-mush-workflow-enabled.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/2927225777027586904'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/2927225777027586904'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2010/02/new-release-of-mush-workflow-enabled.html' title='New release of MuSH – Workflow Enabled ‘TinyURL’ for SharePoint v2'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-5034969418341672109</id><published>2010-02-09T14:17:00.001Z</published><updated>2010-02-09T14:23:41.299Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='News'/><category scheme='http://www.blogger.com/atom/ns#' term='WPP'/><category scheme='http://www.blogger.com/atom/ns#' term='Products'/><category scheme='http://www.blogger.com/atom/ns#' term='Workflow'/><category scheme='http://www.blogger.com/atom/ns#' term='Articles'/><title type='text'>SharePoint Workflow Power Pack User Guide – Creating custom methods</title><content type='html'>&lt;p&gt;&lt;img style="position: relative; border-right-width: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; margin-left: 15px; border-left-width: 0px; top: -23px; margin-right: 0px" title="User-Guide" border="0" alt="User-Guide" align="right" src="http://lh4.ggpht.com/_IgJp5HQ80aU/S3Fuf7WHqdI/AAAAAAAAAMI/W6J4fpBymbw/User-Guide%5B5%5D.jpg?imgmax=800" width="130" height="167"&gt; In part 4 of our series of &lt;a href="http://www.muhimbi.com/support/documentation/Workflow-Power-Pack/User-Guide.aspx"&gt;User Guide&lt;/a&gt; related blog postings for the &lt;a href="http://www.muhimbi.com/blog/2009/12/embed-c-or-vb-code-directly-in.html"&gt;Muhimbi Workflow Power Pack for SharePoint&lt;/a&gt; we show how to create your own methods in a WPP script in order to keep the code organised and easy to maintain.&lt;/p&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2010/02/sharepoint-workflow-power-pack-user.html';&lt;/script&gt;&lt;span style="margin-top: 3px; float: left; margin-right: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;A quick introduction In case you are not familiar with the product: &lt;em&gt;The Muhimbi Workflow Power Pack for SharePoint allows custom C# or VB.NET code to be embedded in SharePoint Designer Workflows without the need to resort to complex Visual Studio based workflows, the development of bespoke Workflow Activities or long development cycles.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;The following Blog postings are part of this User Guide series:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/2009/12/workflow-power-pack-user-guide-language.html"&gt;Language Features&lt;/a&gt;: Discusses the &lt;em&gt;script like&lt;/em&gt; syntax, the generic workflow action and condition, passing parameters, returning values from a workflow and using the &lt;em&gt;MyWorkflow&lt;/em&gt; property.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/2009/12/sharepoint-workflow-power-pack-user.html"&gt;Embedding .net code in a Workflow Condition&lt;/a&gt;: Provides a number of examples of how to use the &lt;em&gt;Evaluate Custom Code&lt;/em&gt; condition to carry out basic as well as complex conditional tasks.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/2009/12/sharepoint-workflow-power-pack-user_22.html"&gt;Embedding .net code in a Workflow Action&lt;/a&gt;: Contains a number of examples of how to use the &lt;em&gt;Execute Custom Code&lt;/em&gt;&amp;nbsp; to basically carry out any action you can think of in a SharePoint Designer Workflow.&lt;br&gt;&amp;nbsp; &lt;li&gt;Creating Custom Methods (this article): Shows how to create your own methods in your scripts in order to keep the code organised and easy to maintain. &lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;br&gt;&amp;nbsp;&lt;br&gt;&lt;/p&gt; &lt;p&gt; &lt;hr align="center" width="250"&gt;  &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;br&gt;Due to its &lt;i&gt;scripting like&lt;/i&gt; approach, the Workflow Power Pack does not allow regular .NET methods to be created. However, by cleverly using delegates you can create your own reusable pieces of code. &lt;/p&gt; &lt;p&gt;To facilitate this, the following delegates can be used in addition to the normal delegates available in the .net framework. Note that this only works for C# as VB.net does not allow anonymous methods to be created. &lt;br&gt;&amp;nbsp; &lt;p&gt;&lt;font size="2" face="Courier New"&gt;delegate void WorkflowMethod(params object[] parameters); &lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font size="2" face="Courier New"&gt;delegate object WorkflowFunction(params object[] parameters); &lt;/font&gt; &lt;p&gt;&lt;font size="2" face="Courier New"&gt;delegate void WorkflowMethod&amp;lt;ParameterType&amp;gt;(params ParameterType[] parameters); &lt;/font&gt; &lt;p&gt;&lt;font size="2" face="Courier New"&gt;delegate ReturnType WorkflowFunction&amp;lt;ParameterType, ReturnType&amp;gt;(params ParameterType[] parameters);&lt;/font&gt;  &lt;p&gt;&amp;nbsp;&lt;br&gt;There is no need to add these delegates to your WPP Code, they are added automatically.  &lt;p&gt;&lt;font color="white"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt; &lt;table border="1" cellspacing="0" cellpadding="0" width="707"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" width="221"&gt; &lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;Delegate name&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="484"&gt; &lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;Description&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="221"&gt; &lt;p&gt;&lt;font size="2"&gt;WorkflowMethod&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="484"&gt; &lt;p&gt;&lt;font size="2"&gt;Method with a &lt;i&gt;void&lt;/i&gt; return type. Accepts any number of &lt;i&gt;Object&lt;/i&gt; based parameters that can be accessed from the delegate body using the &lt;i&gt;parameters&lt;/i&gt; array. &lt;/font&gt; &lt;p&gt;&lt;font size="2"&gt;Parameters may need to be cast to the correct type before they can be used.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="221"&gt; &lt;p&gt;&lt;font size="2"&gt;WorkflowFunction&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="484"&gt; &lt;p&gt;&lt;font size="2"&gt;Method using a return type of &lt;i&gt;Object&lt;/i&gt;. Accepts any number of &lt;i&gt;Object&lt;/i&gt; based parameters that can be accessed from the delegate body using the &lt;i&gt;parameters&lt;/i&gt; array. &lt;/font&gt; &lt;p&gt;&lt;font size="2"&gt;Parameters may need to be cast to the correct type before they can be used.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="221"&gt; &lt;p&gt;&lt;font size="2"&gt;WorkflowMethod (Using generics)&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="484"&gt; &lt;p&gt;&lt;font size="2"&gt;Generics based version that allows strongly typed parameters to be passed.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="221"&gt; &lt;p&gt;&lt;font size="2"&gt;WorkflowFunction (Using generics)&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="484"&gt; &lt;p&gt;&lt;font size="2"&gt;Generics based version that allows strongly typed parameters to be passed and returned&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&lt;font color="#ffffff"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;The example provided below creates a generic &lt;i&gt;Debug&lt;/i&gt; method to concatenate information to a string. This string is then returned as the workflow’s &lt;i&gt;ReturnValue&lt;/i&gt;, from where it can be written to the Workflow History. &lt;br&gt;&amp;nbsp; &lt;div style="padding-bottom: 8pt; padding-left: 8pt; padding-right: 8pt; font-family: consolas; background: black; color: white; font-size: 8pt; font-weight: bold; padding-top: 8pt"&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; debugString = &lt;span style="color: #ffc66d"&gt;String&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.Empty;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;WorkflowMethod&amp;lt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt;&lt;span style="font-weight: normal"&gt;&amp;gt; Debug = &lt;/span&gt;&lt;span style="color: #cc7832"&gt;delegate&lt;/span&gt;(&lt;span style="color: #cc7832"&gt;string&lt;/span&gt;[] parameters)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; debugString += parameters[&lt;span style="color: #6897bb"&gt;0&lt;/span&gt;] + &lt;span style="color: #a5c25c"&gt;"\r\n"&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;};&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;WorkflowFunction Calculate = &lt;span style="color: #cc7832"&gt;delegate&lt;/span&gt;(&lt;span style="color: #cc7832"&gt;object&lt;/span&gt;[] parameters)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;return&lt;/span&gt; (&lt;span style="color: #cc7832"&gt;int&lt;/span&gt;)parameters[&lt;span style="color: #6897bb"&gt;0&lt;/span&gt;] + (&lt;span style="color: #cc7832"&gt;int&lt;/span&gt;)parameters[&lt;span style="color: #6897bb"&gt;1&lt;/span&gt;];&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;};&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;WorkflowFunction&amp;lt;&lt;span style="color: #cc7832"&gt;int&lt;/span&gt;, &lt;span style="color: #cc7832"&gt;string&lt;/span&gt;&lt;span style="font-weight: normal"&gt;&amp;gt; Calculate2 = &lt;/span&gt;&lt;span style="color: #cc7832"&gt;delegate&lt;/span&gt;(&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;int&lt;/span&gt;[] parameters)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;return&lt;/span&gt; (parameters[&lt;span style="color: #6897bb"&gt;0&lt;/span&gt;] + parameters[&lt;span style="color: #6897bb"&gt;1&lt;/span&gt;]).ToString();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;};&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;Debug(&lt;span style="color: #a5c25c"&gt;"Hello"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;Debug(&lt;span style="color: #a5c25c"&gt;"World"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;Debug(Calculate(&lt;span style="color: #6897bb"&gt;1&lt;/span&gt;, &lt;span style="color: #6897bb"&gt;2&lt;/span&gt;).ToString());&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;Debug(Calculate2(&lt;span style="color: #6897bb"&gt;3&lt;/span&gt;, &lt;span style="color: #6897bb"&gt;4&lt;/span&gt;));&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;MyWorkflow.ReturnValue = debugString;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;font color="#ffffff"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-5034969418341672109?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/5034969418341672109/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2010/02/sharepoint-workflow-power-pack-user.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/5034969418341672109'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/5034969418341672109'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2010/02/sharepoint-workflow-power-pack-user.html' title='SharePoint Workflow Power Pack User Guide – Creating custom methods'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-1902073903170541710</id><published>2010-02-09T11:25:00.001Z</published><updated>2010-02-09T14:29:39.319Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='News'/><category scheme='http://www.blogger.com/atom/ns#' term='WPP'/><category scheme='http://www.blogger.com/atom/ns#' term='Products'/><category scheme='http://www.blogger.com/atom/ns#' term='Workflow'/><title type='text'>Workflow Power Pack 1.1 - Embed C#/VB code in SharePoint Designer Workflows</title><content type='html'>&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="WPPBox" border="0" alt="WPPBox" align="right" src="http://lh3.ggpht.com/_IgJp5HQ80aU/S3FGE9ZKwsI/AAAAAAAAAL4/d0I964eDDv4/WPPBox%5B5%5D.jpg?imgmax=800" width="200" height="183"&gt; I can’t believe it has only been 6 weeks since &lt;a href="http://www.muhimbi.com/blog/2009/12/embed-c-or-vb-code-directly-in.html"&gt;we launched&lt;/a&gt; the &lt;a href="http://www.muhimbi.com/Products/Workflow-Power-Pack-for-SharePoint/summary.aspx"&gt;Workflow Power Pack for SharePoint&lt;/a&gt;. We are getting great feedback from our customers, who seem to universally love the product. The support call from one frustrated SharePoint Designer workflow developer who was almost in tears stood out particularly.&lt;/p&gt; &lt;p&gt;The version released today adds support for the number one user request, which is the ability to add your own custom methods to the code to allow some degree of usability and reduce the size of scripts.&amp;nbsp; &lt;a href="http://www.muhimbi.com/blog/2010/02/sharepoint-workflow-power-pack-user.html"&gt;Read this post&lt;/a&gt; for more details about how to use this new functionality.&lt;/p&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2010/02/workflow-power-pack-11-embed-cvb-code.html';&lt;/script&gt;&lt;span style="margin-top: 3px; float: left; margin-right: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;A quick introduction for those not familiar with the product: &lt;em&gt;The Muhimbi Workflow Power Pack for SharePoint allows custom C# or VB.NET code to be embedded in SharePoint Designer Workflows without the need to resort to complex Visual Studio based workflows, the development of bespoke Workflow Activities or long development cycles.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;We have been working very hard to write as many blog posts as possible to provide examples of what can be achieved using the product as well as how to integrate the WPP with our other products such as the &lt;a href="http://www.muhimbi.com/Products/PDF-Converter-for-SharePoint/summary.aspx"&gt;PDF Converter&lt;/a&gt; and &lt;a href="http://www.muhimbi.com/Products/SharePoint-URL-Shortener/summary.aspx"&gt;URL Shortener&lt;/a&gt;. Have a look at the following posts:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/2009/12/automatically-create-mirrored.html"&gt;Automatically mirror / sync a SharePoint folder structure&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/2010/01/adding-watermark-to-pdf-file-from.html"&gt;Adding a watermark to a PDF file from a SharePoint Workflow&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/2009/12/create-shortened-tinyurl-links-from.html"&gt;Create Shortened (‘TinyURL’) links from your SharePoint Designer Workflow&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/2009/12/automatically-synchronise-sharepoint.html"&gt;Synchronise SharePoint Lists such as Calendars and Tasks&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/2009/12/send-rich-emails-with-attachments-from.html"&gt;Send rich emails with attachments from a SharePoint Designer Workflow&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/2010/01/configure-pdf-security-from-sharepoint.html"&gt;Configure PDF Security from a SharePoint Workflow&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/2009/12/workflow-power-pack-user-guide-language.html"&gt;User Guide - Language Features&lt;/a&gt;  &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/2009/12/sharepoint-workflow-power-pack-user.html"&gt;User Guide - Embedding .net code in a Workflow Condition&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/2009/12/sharepoint-workflow-power-pack-user_22.html"&gt;User Guide - Embedding .net code in a Workflow Action&lt;/a&gt;.&lt;br&gt;&amp;nbsp; &lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Screenshot-SharePointDesigner450x300" border="0" alt="Screenshot-SharePointDesigner450x300" src="http://lh5.ggpht.com/_IgJp5HQ80aU/S3FGFk1RMCI/AAAAAAAAAL8/Zc3v7NthVic/Screenshot-SharePointDesigner450x300%5B7%5D.jpg?imgmax=800" width="454" height="304"&gt;&lt;/li&gt;&lt;/ul&gt; &lt;div style="position: relative; text-align: center; font-size: 8pt; top: -10px"&gt;&lt;i&gt;Embed C# code directly into a SharePoint Designer workflow&lt;/i&gt;&lt;/div&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;br&gt;The main changes in version 1.1 are as follows: &lt;/p&gt; &lt;table border="0" cellspacing="0" cellpadding="2" width="700"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" width="31"&gt;&lt;font size="2"&gt;743&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" width="667"&gt;&lt;font size="2"&gt;Add Support for Custom methods using Delegates (See details in User Guide)&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top"&gt;&lt;font size="2"&gt;763&lt;/font&gt;&lt;/td&gt; &lt;td valign="top"&gt;&lt;font size="2"&gt;Trial version causes an error when used after a &lt;em&gt;Pause For Duration&lt;/em&gt; activity.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;br&gt;For more information check out the following resources:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://www.muhimbi.com/Products/Workflow-Power-Pack-for-SharePoint.aspx"&gt;Product Page&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/documentation/Workflow-Power-Pack/Release-Notes.aspx"&gt;Release Notes&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/documentation/Workflow-Power-Pack/Administration-Guide.aspx"&gt;Administration Guide&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/documentation/Workflow-Power-Pack/User-Guide.aspx"&gt;User Guide&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/documentation/Workflow-Power-Pack/Screenshots.aspx"&gt;Screenshots&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/faqs.aspx"&gt;FAQ&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/forum.aspx"&gt;Message Board&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/labels/WPP.html"&gt;All Workflow Power Pack related Blog postings&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&amp;nbsp;&lt;br&gt;As always, feel free to &lt;a href="http://www.muhimbi.com/contact.aspx"&gt;contact us using Twitter, our Blog, regular email&lt;/a&gt; or &lt;a href="http://eepurl.com/b6A7"&gt;subscribe to our newsletter&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p align="center"&gt;&lt;a href="http://www.muhimbi.com/Products/Workflow-Power-Pack-for-SharePoint/Download.aspx"&gt;Download your free trial here&lt;/a&gt; (1MB). &lt;/p&gt; &lt;p&gt;&lt;br&gt;&lt;font color="#ffffff"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-1902073903170541710?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/1902073903170541710/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2010/02/workflow-power-pack-11-embed-cvb-code.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/1902073903170541710'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/1902073903170541710'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2010/02/workflow-power-pack-11-embed-cvb-code.html' title='Workflow Power Pack 1.1 - Embed C#/VB code in SharePoint Designer Workflows'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-8778216399745636060</id><published>2010-02-04T11:36:00.001Z</published><updated>2010-02-04T11:41:02.613Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='MuSH'/><category scheme='http://www.blogger.com/atom/ns#' term='WPP'/><category scheme='http://www.blogger.com/atom/ns#' term='PDF Converter'/><category scheme='http://www.blogger.com/atom/ns#' term='Workflow'/><category scheme='http://www.blogger.com/atom/ns#' term='Articles'/><title type='text'>Tuning SharePoint’s workflow engine</title><content type='html'>&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="workflow" border="0" alt="workflow" align="right" src="http://lh3.ggpht.com/_IgJp5HQ80aU/S2qxPG2o19I/AAAAAAAAAL0/-hfuJ0jdCKI/workflow%5B5%5D.jpg?imgmax=800" width="153" height="141"&gt; As most of &lt;a href="http://www.muhimbi.com/products.aspx"&gt;our products&lt;/a&gt; can be used from a SharePoint workflow, it is perhaps useful to know how to tweak SharePoint’s workflow engine for high-load or other specific scenarios.&lt;/p&gt; &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd441390.aspx"&gt;This article&lt;/a&gt; explains in detail what can be tuned and how it can be tuned. If you are in a rush then you can skip over the first 20%.&lt;/p&gt; &lt;p&gt;In summary:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;Workflow Throttle:&lt;/strong&gt; Controls how many workflows can be processing at any one time on the entire server farm. This setting does not control how many workflows can be "In Progress" concurrently, but rather how many can be actively using the processor. When this number is exceeded, workflow instances that are started and events that wake up dehydrated workflows are queued for later processing. The default value is 15. This setting is per farm, so the number of front-end Web servers is irrelevant&lt;br&gt;&lt;br&gt;&lt;font size="2" face="Courier New"&gt;stsadm -o setproperty -pn workflow-eventdelivery-throttle -pv "25"&lt;/font&gt;&lt;br&gt;&amp;nbsp; &lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;strong&gt;Workflow Batch Size: &lt;/strong&gt;Workflows, by their very nature, do not execute in a nonstop, linear fashion. Instead, they run for a little while, pause, run some more, and then pause again, continuing in this manner until the process is complete. Although an outside observer or a developer might disagree, workflows are a collection of batches and the workflow engine is simply a glorified batch controller.&lt;br&gt;&lt;br&gt;&lt;font size="2" face="Courier New"&gt;stsadm -o setproperty -pn workitem-eventdelivery-batchsize -pv "125"&lt;/font&gt;&lt;br&gt;&amp;nbsp; &lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;strong&gt;Workflow Timeout: &lt;/strong&gt;The timeout setting specifies the amount of time (in minutes) in which a workflow timer job must complete before it is considered to have stopped responding and is forced to stop processing. Jobs that time out are returned to the queue to be reprocessed later. The default timeout period is five minutes&lt;br&gt;&lt;br&gt;&lt;font size="2" face="Courier New"&gt;stsadm -o setproperty -pn workflow-eventdelivery-timeout -pv "10"&lt;/font&gt;&lt;br&gt;&amp;nbsp;&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;strong&gt;Workflow Timer Interval:&lt;/strong&gt; The workflow timer interval specifies how often the workflow SPTimer job fires to process pending workflow tasks. This interval also represents the granularity of delay timers within your workflow. If a timer is set to delay for one minute, but the interval timer fires only every five minutes, the workflow delays for five minutes, not one minute&lt;br&gt;&lt;br&gt;&lt;font size="2" face="Courier New"&gt;stsadm -o setproperty -pn job-workflow -pv value -url http://myWssServer&lt;/font&gt;&lt;br&gt;&amp;nbsp;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;For our products you may need to tweak &lt;em&gt;Workflow Timeout&lt;/em&gt; for very long running &lt;a href="http://www.muhimbi.com/Products/PDF-Converter-for-SharePoint/summary.aspx"&gt;PDF Conversions&lt;/a&gt;. Changing the &lt;em&gt;Timer Interval&lt;/em&gt; can be useful during development when using &lt;em&gt;Pause Until&lt;/em&gt; or &lt;em&gt;Pause For&lt;/em&gt; workflow Activities.&lt;/p&gt; &lt;p&gt;&lt;font color="white"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-8778216399745636060?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/8778216399745636060/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2010/02/tuning-sharepoints-workflow-engine.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/8778216399745636060'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/8778216399745636060'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2010/02/tuning-sharepoints-workflow-engine.html' title='Tuning SharePoint’s workflow engine'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-6215154937854055869</id><published>2010-02-02T16:41:00.001Z</published><updated>2010-03-02T16:27:43.034Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='News'/><category scheme='http://www.blogger.com/atom/ns#' term='Articles'/><title type='text'>Using Google AdWords on Content networks, a click-fraud investigation.</title><content type='html'>&lt;p&gt;&lt;i&gt;&lt;img style="border-right-width: 0px; margin: 0px 0px 5px 5px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="THIEFS" border="0" alt="THIEFS" align="right" src="http://lh6.ggpht.com/_IgJp5HQ80aU/S2hVzWOQ_zI/AAAAAAAAALo/iKgCvLr-MCs/THIEFS%5B5%5D.jpg?imgmax=800" width="140" height="135"&gt; The following article is an ‘open Kimono session’ where I discuss some of the internals of my company as well as our marketing program. It is my opinion that we are the victim of click-fraud, however my investigation is not 100% scientific and I have had to make some assumptions based on observations and time constraints. Please draw your own conclusion and consider everyone innocent until proven guilty. The figures, charts and tables presented in this article originate from Google’s own Analytics and AdWords software.&lt;/i&gt;&lt;/p&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2010/02/using-google-adwords-on-content.html';&lt;/script&gt;&lt;span style="margin-top: 3px; float: left; margin-right: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;font color="#ff0000"&gt;Update: Latest developments and responses from Google can be found at the end of this post.&lt;/font&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;After witnessing unexpected browsing behaviour from visitors who arrived on our site via a Google AdWords campaign that we ran a year ago for our &lt;a href="http://www.muhimbi.com/Products/PDF-Converter-for-SharePoint/summary.aspx"&gt;PDF Converter for SharePoint&lt;/a&gt;, I was pretty sure that we were the victim of &lt;em&gt;click-fraud&lt;/em&gt;.&lt;/p&gt; &lt;p&gt;Unfortunately, due to a lack of time and detailed figures to back up my suspicions, I decided not to pursue the matter at the time. However, after recently analysing another campaign it became clear that something suspicious is going on. Naturally it is not Google who is committing the fraud, but they are not doing enough to prevent it either. &lt;/p&gt; &lt;p&gt;Note that Google has settled &lt;a href="http://www.clickz.com/3590251"&gt;a click-fraud related class action lawsuit&lt;/a&gt; in 2006 for $90M, a drop in the ocean compared to their level of revenue. The problems appear to be ongoing, read on for my findings.  &lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;b&gt;What is Google AdWords?&lt;/b&gt;  &lt;p&gt;Ever wonder how Google make tens of billions of dollars each year? One word: &lt;i&gt;Advertising&lt;/i&gt;! AdWords is the platform that allows customers to specify keywords, bids and budget for displaying adverts next to Google’s search results as well as in-line on any website that is willing to display adverts in exchange for a share in the revenue.  &lt;p&gt;When creating a campaign you can specify where the ads appear:  &lt;ol&gt; &lt;li&gt;&lt;b&gt;In Google’s Search Results:&lt;/b&gt; Based on the search terms and the keywords specified, relevant adverts are displayed next to and above the search results. The more you are willing to pay, the higher the advert will be displayed, increasing the chances of a user clicking it. Every time an advert is clicked, Google charges the advertiser a fee. As Google’s site is a trusted entity, this way of advertising is relatively fraud proof. In all fairness it appears to work exceptionally well and Muhimbi probably could not survive without it.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;b&gt;On the content network: &lt;/b&gt;This is where I suspect the majority of fraud is taking place. Anyone who can host any kind of content, e.g. a blog, can sign up as an affiliate and place Google ads in their content. Every time an advert is clicked on the content network Google charges the advertiser and part of the income is paid to the ‘owner’ of the content. &lt;b&gt;&lt;/b&gt;&lt;br&gt;&amp;nbsp;&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;Although Google is putting a lot of effort in preventing fraud, the engineer in me can think of many ways to abuse the content network program, particularly using cheap labour, proxy servers and spyware like applications to simulate real user clicks.&lt;b&gt;&lt;/b&gt;  &lt;p&gt;For more detail &lt;a href="http://en.wikipedia.org/wiki/Google_Adwords"&gt;read Wikipedia’s definition of the AdWords platform&lt;/a&gt;.  &lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;b&gt;Muhimbi’s market and products&lt;/b&gt;  &lt;p&gt;What makes this investigation relatively easy is the fact that we serve a niche market. All our products are aimed at corporate IT departments for use in their SharePoint environment. The campaign discussed in this article is for our &lt;a href="http://www.muhimbi.com/Products/Workflow-Power-Pack-for-SharePoint/summary.aspx"&gt;Workflow Power Pack&lt;/a&gt;, a product that allows &lt;i&gt;SharePoint Designer&lt;/i&gt; developers to embed C# or VB code into their workflows. A great product, but I believe there is a box shot of our product next to the definition of the word &lt;i&gt;niche&lt;/i&gt;.  &lt;p&gt;We are a small, but extremely committed company, which makes it difficult to swallow that our hard earned money appears to be used for funding criminal activity.  &lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;b&gt;Normal, genuine, users&lt;/b&gt;  &lt;p&gt;Based on our experience with other campaigns as well as ‘organic visitors’ who visit our site via external links or regular Google searches, our normal audience has the following characteristics:  &lt;ol&gt; &lt;li&gt;When we send a newsletter to these users, the email rarely bounces. &lt;br&gt;&amp;nbsp; &lt;li&gt;They visit during weekdays. During the weekend our site has 75% less visitors compared to weekdays. &lt;br&gt;&amp;nbsp; &lt;li&gt;They arrive on our site via Google with relevant keyword searches or via links from external sites that are relevant to our niche. &lt;br&gt;&amp;nbsp; &lt;li&gt;They browse around before going to the download page. Only 41% go from the landing page directly to the download page. &lt;br&gt;&amp;nbsp; &lt;li&gt;Roughly half of interested visitors contact our support / sales department at some stage for further information. &lt;br&gt;&amp;nbsp;&lt;/li&gt;&lt;/ol&gt; &lt;p align="center"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="clip_image002[7]" border="0" alt="clip_image002[7]" src="http://lh5.ggpht.com/_IgJp5HQ80aU/S2hVz_89aWI/AAAAAAAAALs/LHvyMp0NKr8/clip_image002%5B7%5D%5B7%5D.jpg?imgmax=800" width="624" height="140"&gt;&lt;i&gt;Regular visits by day of the week. Guess which data points represent the weekend.&lt;/i&gt;  &lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;b&gt;Evil users&lt;/b&gt;  &lt;p&gt;The usage pattern of these alleged fraudulent users is completely different:  &lt;ol&gt; &lt;li&gt;A large proportion of newsletters sent to these users bounce. &lt;br&gt;&amp;nbsp; &lt;li&gt;They visit every day of the week including the weekend. &lt;br&gt;&amp;nbsp; &lt;li&gt;They arrive on our site via questionable, unrelated sites. More about this later. &lt;br&gt;&amp;nbsp; &lt;li&gt;75% of the users go directly to the download page from the landing page without getting any further information about the product. &lt;br&gt;&amp;nbsp; &lt;li&gt;None get in contact with our support / sales department to request any kind of information. I would like to think the information on the site is crystal clear, however this does not match the pattern we see from other products and campaigns. &lt;br&gt;&amp;nbsp; &lt;li&gt;They spend an average of 1 minute on the site. I am not sure if this is the minimum that Google Analytics reports, but these people are clearly ‘very committed’. &lt;br&gt;&amp;nbsp;&lt;/li&gt;&lt;/ol&gt; &lt;p align="center"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="clip_image004[7]" border="0" alt="clip_image004[7]" src="http://lh4.ggpht.com/_IgJp5HQ80aU/S2hV0BuDaqI/AAAAAAAAALw/p_AAO57qhls/clip_image004%5B7%5D%5B6%5D.jpg?imgmax=800" width="624" height="140"&gt;&lt;i&gt;Visits by day of the week for pages related to this particular campaign. No weekend dips, clearly hard workers.&lt;/i&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp; &lt;p&gt;So why do these alleged fraudulent users go through the effort of downloading our software and registering for newsletters after clicking the advertisement, which is when they make their money? The reason behind this is that many Google campaigns as well as marketing professionals measure the success of their campaign based on &lt;em&gt;conversions. &lt;/em&gt;For example:  &lt;ol&gt; &lt;li&gt;A user enters the site via an AdWords campaign and downloads the software. This is considered a conversion and a sign of a campaign being successful. The marketing executive will get a pat on the back from the CEO and everyone is happy (initially).&lt;br&gt;&amp;nbsp; &lt;li&gt;A user enters the site via an AdWords campaign and subscribes to a newsletter. This is considered a conversion as well resulting in &lt;em&gt;CEO –&amp;gt; pats marketing on back–&amp;gt; Happy –&amp;gt; time expires –&amp;gt; Sad –&amp;gt; Fired –&amp;gt; Divorce –&amp;gt; Death&lt;/em&gt; (See the pain these people are causing!)&lt;br&gt;&amp;nbsp;&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;Clever marketing people and, if configured that way Google AdWords, measure conversions and allocate more budget to sites that generate these conversions. A good reason for fraudsters to simulate some activity after clicking an advertisement.  &lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;b&gt;Which sites are the worst offenders?&lt;/b&gt;  &lt;p&gt;It should come as no surprise that sites that allow anonymous users to host their own content and insert Google advertisements are the worst offenders as it is almost impossible to trace these people. From a geographic perspective it appears that Chinese web sites are the worst, but many other countries are just as bad.  &lt;p&gt;Our advert has been displayed 2.5 million times on 767 sites over the course of one month. 611 different sites have referred at least one visitor. Out of those sites I consider about 60 sites relevant in the loosest sense of the word (Intentionally or not, &lt;em&gt;eggheadcafe.com&lt;/em&gt; for example is legit although until recently very mischievous in the way they presented and positioned their advertisements to make them look like clickable answers to questions. They still do it on some threads, but not as bad as it used to be).  &lt;p&gt;76 sites had an amazing 100% click through ratio, 213 with a CTR of more than 20%, 345 with more than 10% and 450 with more than 1% (which is still an amazing rate considering &lt;em&gt;mail.google.com&lt;/em&gt; has a 0.02% CTR).  &lt;p&gt;Sites such as divxphoto.com (domain for sale) I consider to be irrelevant as the domain is for sale and doesn’t actually display any advertisements(!!!!!) Most of the other sites on the list can be categorised as &lt;i&gt;domain for sale&lt;/i&gt;, &lt;i&gt;dodgy software download site&lt;/i&gt;, &lt;i&gt;driver download site&lt;/i&gt; or &lt;i&gt;rubbish content aggregation site&lt;/i&gt;.  &lt;p&gt;&amp;nbsp; &lt;p&gt;Listed below are the top 15 sites by highest number of advertising clicks.  &lt;table border="0" cellspacing="0" cellpadding="0" width="687"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;b&gt;&lt;font size="1"&gt;Domain&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;b&gt;&lt;font size="1"&gt;Clicks&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;b&gt;&lt;font size="1"&gt;Impr.&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="42"&gt; &lt;p&gt;&lt;b&gt;&lt;font size="1"&gt;CTR&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="460"&gt; &lt;p&gt;&lt;b&gt;&lt;font size="1"&gt;&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f2dbdb"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;thaimanga.net&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;249&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;485640&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="42"&gt; &lt;p&gt;&lt;font size="1"&gt;0.05%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="460"&gt; &lt;p&gt;&lt;font size="1"&gt;Manga comics, not relevant to our advert.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f6e1a4"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;softpedia.com&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;223&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;158636&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="42"&gt; &lt;p&gt;&lt;font size="1"&gt;0.14%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="460"&gt; &lt;p&gt;&lt;font size="1"&gt;Download site, not relevant &lt;/font&gt;&lt;font size="1"&gt;to our advert.&lt;/font&gt; &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f6e1a4"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;incoto.com&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;178&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;192949&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="42"&gt; &lt;p&gt;&lt;font size="1"&gt;0.09%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="460"&gt; &lt;p&gt;&lt;font size="1"&gt;Some Chinese site&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f6e1a4"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;webs.com&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;159&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;19109&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="42"&gt; &lt;p&gt;&lt;font size="1"&gt;0.83%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="460"&gt; &lt;p&gt;&lt;font size="1"&gt;Create your own website service, which makes it easy to host dodgy content.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f6e1a4"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;conduit.com&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;139&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;7221&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="42"&gt; &lt;p&gt;&lt;font size="1"&gt;1.92%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="460"&gt; &lt;p&gt;&lt;font size="1"&gt;Browser toolbar company. God knows what is going on here.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #eaf1dd"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;mail.google.com&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;74&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;399955&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="42"&gt; &lt;p&gt;&lt;font size="1"&gt;0.02%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="460"&gt; &lt;p&gt;&lt;font size="1"&gt;Wow, a legit one&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #eaf1dd"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;eggheadcafe.com&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;53&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;109068&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="42"&gt; &lt;p&gt;&lt;font size="1"&gt;0.05%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="460"&gt; &lt;p&gt;&lt;font size="1"&gt;Legit, but sometimes misleading i.m.o.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f6e1a4"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;csdn.net&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;50&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;146830&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="42"&gt; &lt;p&gt;&lt;font size="1"&gt;0.03%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="460"&gt; &lt;p&gt;&lt;font size="1"&gt;Chinese programming site, maybe legit, probably not.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f6e1a4"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;gyanii.com&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;48&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;7481&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="42"&gt; &lt;p&gt;&lt;font size="1"&gt;0.64%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="460"&gt; &lt;p&gt;&lt;font size="1"&gt;Software download site, looks rubbish and full of advertisements.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f6e1a4"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;blogspot.com&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;41&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;13915&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="42"&gt; &lt;p&gt;&lt;font size="1"&gt;0.29%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="460"&gt; &lt;p&gt;&lt;font size="1"&gt;Host your own content. Partly legit.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #eaf1dd"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;csharpfr.com&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;38&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;12915&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="42"&gt; &lt;p&gt;&lt;font size="1"&gt;0.29%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="460"&gt; &lt;p&gt;&lt;font size="1"&gt;French C# site, probably legit.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f6e1a4"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;pin5i.com&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;34&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;15196&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="42"&gt; &lt;p&gt;&lt;font size="1"&gt;0.22%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="460"&gt; &lt;p&gt;&lt;font size="1"&gt;Chinese programming site. Could be legit or just an aggregator. My Chinese isn’t what it used to be.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #eaf1dd"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;dotnet-news.com&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;33&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="38"&gt; &lt;p&gt;&lt;font size="1"&gt;2806&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="42"&gt; &lt;p&gt;&lt;font size="1"&gt;1.18%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="460"&gt; &lt;p&gt;&lt;font size="1"&gt;Another French .net site related to csharpfr.com. Possibly legit, but I wonder why they are generating so many clicks&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p align="center"&gt;&lt;i&gt;Green: Most likely legit - Amber: Likely to be illegitimate - Red: Almost certainly illegitimate&lt;/i&gt;  &lt;p&gt;&amp;nbsp; &lt;p&gt;Listed below are the top 15 Sites by Click Through Ratio with more than 25 impressions (otherwise the table would contain 76 sites with a 100% CTR after a single impression, which is rather useless).  &lt;table border="0" cellspacing="0" cellpadding="0" width="686"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;b&gt;&lt;font size="1"&gt;Domain&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="36"&gt; &lt;p&gt;&lt;b&gt;&lt;font size="1"&gt;Clicks&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="39"&gt; &lt;p&gt;&lt;b&gt;&lt;font size="1"&gt;Impr.&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="43"&gt; &lt;p&gt;&lt;b&gt;&lt;font size="1"&gt;CTR&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="459"&gt; &lt;p&gt;&lt;b&gt;&lt;font size="1"&gt;&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f2dbdb"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;9mine.com&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="36"&gt; &lt;p&gt;&lt;font size="1"&gt;9&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="39"&gt; &lt;p&gt;&lt;font size="1"&gt;34&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="43"&gt; &lt;p&gt;&lt;font size="1"&gt;26.47%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="459"&gt; &lt;p&gt;&lt;font size="1"&gt;Free games&lt;/font&gt;&lt;font size="1"&gt;, not relevant &lt;/font&gt;&lt;font size="1"&gt;to our advert.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f2dbdb"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;hbrsd.com&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="36"&gt; &lt;p&gt;&lt;font size="1"&gt;19&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="39"&gt; &lt;p&gt;&lt;font size="1"&gt;87&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="43"&gt; &lt;p&gt;&lt;font size="1"&gt;21.84%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="459"&gt; &lt;p&gt;&lt;font size="1"&gt;Domain for sale, no ads. Who knows where the clicks came from.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f6e1a4"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;5dmail.net&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="36"&gt; &lt;p&gt;&lt;font size="1"&gt;6&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="39"&gt; &lt;p&gt;&lt;font size="1"&gt;36&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="43"&gt; &lt;p&gt;&lt;font size="1"&gt;16.67%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="459"&gt; &lt;p&gt;&lt;font size="1"&gt;Chinese site, could be legit, could be aggregator.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f6e1a4"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;boxsoftware.net&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="36"&gt; &lt;p&gt;&lt;font size="1"&gt;5&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="39"&gt; &lt;p&gt;&lt;font size="1"&gt;37&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="43"&gt; &lt;p&gt;&lt;font size="1"&gt;13.51%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="459"&gt; &lt;p&gt;&lt;font size="1"&gt;Spanish software download site&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f2dbdb"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;meiying.com&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="36"&gt; &lt;p&gt;&lt;font size="1"&gt;6&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="39"&gt; &lt;p&gt;&lt;font size="1"&gt;48&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="43"&gt; &lt;p&gt;&lt;font size="1"&gt;12.50%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="459"&gt; &lt;p&gt;&lt;font size="1"&gt;Dodgy site to display just SharePoint related ads without any content.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f2dbdb"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;myalbums.tk&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="36"&gt; &lt;p&gt;&lt;font size="1"&gt;18&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="39"&gt; &lt;p&gt;&lt;font size="1"&gt;160&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="43"&gt; &lt;p&gt;&lt;font size="1"&gt;11.25%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="459"&gt; &lt;p&gt;&lt;font size="1"&gt;Dodgy site to display just MS Development related ads without any content.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f6e1a4"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;codehaus.org&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="36"&gt; &lt;p&gt;&lt;font size="1"&gt;6&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="39"&gt; &lt;p&gt;&lt;font size="1"&gt;54&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="43"&gt; &lt;p&gt;&lt;font size="1"&gt;11.11%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="459"&gt; &lt;p&gt;&lt;font size="1"&gt;Some open source site. Could be legit, but not relevant so doesn't explain the high CTR.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f2dbdb"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;micorcsolft.com.cn&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="36"&gt; &lt;p&gt;&lt;font size="1"&gt;8&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="39"&gt; &lt;p&gt;&lt;font size="1"&gt;76&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="43"&gt; &lt;p&gt;&lt;font size="1"&gt;10.53%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="459"&gt; &lt;p&gt;&lt;font size="1"&gt;Site doesn't even exist.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f2dbdb"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;douziwang.cn&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="36"&gt; &lt;p&gt;&lt;font size="1"&gt;4&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="39"&gt; &lt;p&gt;&lt;font size="1"&gt;40&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="43"&gt; &lt;p&gt;&lt;font size="1"&gt;10.00%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="459"&gt; &lt;p&gt;&lt;font size="1"&gt;Similar to meiying.com. Dodgy site to just display ads for MS Dev tools&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f2dbdb"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;paramegsoft.com&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="36"&gt; &lt;p&gt;&lt;font size="1"&gt;3&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="39"&gt; &lt;p&gt;&lt;font size="1"&gt;30&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="43"&gt; &lt;p&gt;&lt;font size="1"&gt;10.00%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="459"&gt; &lt;p&gt;&lt;font size="1"&gt;Arabic online games&lt;/font&gt;&lt;font size="1"&gt;, not relevant &lt;/font&gt;&lt;font size="1"&gt;to our advert.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f6e1a4"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;kidwaresoftware.com&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="36"&gt; &lt;p&gt;&lt;font size="1"&gt;4&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="39"&gt; &lt;p&gt;&lt;font size="1"&gt;46&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="43"&gt; &lt;p&gt;&lt;font size="1"&gt;8.70%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="459"&gt; &lt;p&gt;&lt;font size="1"&gt;Possibly legit site, but not relevant so doesn't explain the high CTR&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f6e1a4"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;thaiboxsoftware.com&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="36"&gt; &lt;p&gt;&lt;font size="1"&gt;3&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="39"&gt; &lt;p&gt;&lt;font size="1"&gt;38&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="43"&gt; &lt;p&gt;&lt;font size="1"&gt;7.89%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="459"&gt; &lt;p&gt;&lt;font size="1"&gt;Thai software download site. Glad to see we are so popular in Thailand&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f2dbdb"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;netcsharp.cn&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="36"&gt; &lt;p&gt;&lt;font size="1"&gt;3&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="39"&gt; &lt;p&gt;&lt;font size="1"&gt;40&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="43"&gt; &lt;p&gt;&lt;font size="1"&gt;7.50%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="459"&gt; &lt;p&gt;&lt;font size="1"&gt;Malware site as reported by Google Chrome, yet Google allow advertisements.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f6e1a4"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;download3k.com&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="36"&gt; &lt;p&gt;&lt;font size="1"&gt;3&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="39"&gt; &lt;p&gt;&lt;font size="1"&gt;45&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="43"&gt; &lt;p&gt;&lt;font size="1"&gt;6.67%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="459"&gt; &lt;p&gt;&lt;font size="1"&gt;Another software download site&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr style="background-color: #f6e1a4"&gt; &lt;td valign="top" width="107"&gt; &lt;p&gt;&lt;font size="1"&gt;technos-sources.com&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="36"&gt; &lt;p&gt;&lt;font size="1"&gt;2&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="39"&gt; &lt;p&gt;&lt;font size="1"&gt;30&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="43"&gt; &lt;p&gt;&lt;font size="1"&gt;6.67%&lt;/font&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="459"&gt; &lt;p&gt;&lt;font size="1"&gt;French tech site. Could be legit, could be aggregator. Doesn't explain the high CTR.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p align="center"&gt;&lt;i&gt;Green: Most likely legit - Amber: Likely to be illegitimate - Red: Almost certainly illegitimate&lt;/i&gt;  &lt;p&gt;&amp;nbsp;&lt;br&gt;I realise that detecting and solving click fraud is much more difficult than actually causing it, especially without access to key information such as site demographics, visitor behaviour, click streams and conversion data. On the other hand, as Google Analytics tracks the Muhimbi Site, they actually have most of this data. I will present my findings to Google and give them a chance to respond and hopefully improve the situation for everyone. Perhaps some kind of validation system or list of ‘trusted sites’ could be created by Google. &lt;/p&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2010/02/using-google-adwords-on-content.html';&lt;/script&gt;&lt;span style="margin-top: 3px; float: right; margin-left: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt;&lt;!--
&lt;span style="margin-top: 3px; float: left; margin-right: 5px"&gt;&lt;script type="text/javascript"&gt;
digg_url = 'http://www.muhimbi.com/blog/2010/02/using-google-adwords-on-content.html';
&lt;/script&gt;&lt;script src="http://digg.com/tools/diggthis.js" type="text/javascript"&gt;&lt;/script&gt;&lt;/span&gt;
--&gt; &lt;p&gt;As a Google shareholder I wonder how much of Google’s income actually comes from this kind of alleged criminal activity. According to Google: “…&lt;i&gt;we manage the problem of invalid clicks very well. We have a large team of expert engineers and analysts devoted to it. By far, most invalid clicks are caught by our automatic filters and discarded *before* they reach an advertiser’s bill. And for the clicks that are not caught in advance, advertisers can notify Google and ask for reimbursement.”&lt;/i&gt;  &lt;p&gt;This situation cannot continue any longer. I am naturally upset that my company appears to be the victim of fraud, but what about the thousands (millions?) of other advertisers who do not have the knowledge or resources to detect fraud? It should not be up to the customers to research and report fraud, Google should step up its game and clean up its act, no matter how difficult or painful it is.&amp;nbsp; &lt;p&gt;So, is Google guilty of fraud? I seriously doubt it, however they appear to be profiteering from other people’s criminal activity in a manner not dissimilar to the way illegal media sharing sites are behaving. “&lt;i&gt;We are not doing anything illegal, we can’t help it that other people upload illegal movies / music / software / &amp;lt;insert excuse here&amp;gt; to our site even though it has clearly been designed for this purpose.” &lt;/i&gt; &lt;p&gt;… Not good enough. To be continued. &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;02-Feb-2010 - Update 1: We are clearly not the only party experiencing click-fraud. For more information visit the links below:&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://www.daniweb.com/news/story258407.html"&gt;Internet HoneyGrid reveals 95% of User Generated Content is spam or malicious&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.thedomains.com/2010/02/02/can-a-company-selling-ppc-ads-eliminate-liability-for-click-fraud-by-just-saying-so/comment-page-1/#comment-25856"&gt;Can A Company Selling PPC Ads Eliminate Liability For Click Fraud By Just Saying So?&lt;/a&gt;  &lt;li&gt;&lt;a href="http://www.businesswire.com/portal/site/cityaustin/?ndmViewId=news_view&amp;amp;newsId=20100119006701&amp;amp;newsLang=en"&gt;Industry Click Fraud Rate at 15.3 Percent for Q4 2009&lt;/a&gt;  &lt;li&gt;&lt;a href="http://www.clickforensics.com/resources/click-fraud-index.html"&gt;ClickForensics – Click Fraud Index&lt;/a&gt;  &lt;li&gt;&lt;a href="http://www.forbes.com/2010/01/12/google-click-fraud-tech-security-trafficsolar.html"&gt;Forbes - Google Faces The Slickest Click Fraud Yet&lt;/a&gt;  &lt;li&gt;&lt;a href="http://www.blogsdn.com/238/how-to-avoid-google-adsense-click-fraud-in-any-online-business.html"&gt;How To Avoid Google Adsense Click Fraud In Any Online Business&lt;/a&gt;  &lt;li&gt;&lt;a href="http://www.blogsdn.com/568/advertising-click-fraud-rampant-online.html"&gt;Advertising Click Fraud Rampant Online?&lt;/a&gt;  &lt;li&gt;&lt;a href="http://www.kikabink.com/news/google-ignoring-benefiting-from-click-fraud/comment-page-1/#comment-7428"&gt;Google Ignoring (Benefiting From) Click Fraud?&lt;/a&gt;  &lt;li&gt;&lt;a href="http://www.benedelman.org/news/011210-1.html"&gt;Google Click Fraud Inflates Conversion Rates and Tricks Advertisers into Overpaying&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a href="https://adwords.google.com/support/aw/bin/request.py?hl=en-uk&amp;amp;clickquality=1&amp;amp;ctx=clickqual"&gt;Report Google click-fraud here&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&amp;nbsp; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;18-Feb-2010 - Update 2: Google have responded and claim that only a small percentage of the clicks are fraudulent. The remaining clicks are all part of normal user activity. It appears their response is largely automated so I have replied back asking for further details as I don’t accept their findings. I find it astonishing how much they downplay the issue of click-fraud. Apparently it is up to me to manually exclude domains that I consider not to be relevant. This is just laughable.&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;19-Feb-2010 – Update 3: &lt;/strong&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;Typos may earn Google $500m a year – &lt;a href="http://www.newscientist.com/article/dn18542-typos-may-earn-google-500m-a-year.html"&gt;NewScientist&lt;/a&gt;, &lt;a href="http://blogs.zdnet.com/BTL/?p=30897&amp;amp;tag=mncol;txt"&gt;ZDNet&lt;/a&gt;, &lt;a href="http://www.benedelman.org/typosquatting/pop.html"&gt;Harvard University Research&lt;/a&gt;&lt;/strong&gt;  &lt;li&gt;&lt;a href="http://blog.ericgoldman.org/archives/2007/06/google_sued_in.htm"&gt;Google Sued in Domainer Lawsuit--Vulcan Golf v. Google&lt;/a&gt;&lt;strong&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;01-Mar-2010 – Update 4: Received another reply from Google AdWords support. They have disabled some of the accounts that have caused fraudulent clicks, but they are not allowed to tell which clicks were the fraudulent ones. Apparently it is up to us to police Google’s content network, painstakingly go through all reports, check out each domain and then take Google’s word for it about them taking the appropriate action. In light of my findings, Google’s word is not worth much to me at the moment, even if they have the best of intentions.&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://www.ppchero.com/friends-google-adwords-search-partner-includes-parked-domains/"&gt;Yes Friends, Google AdWords’ Search Partners Includes Parked Domains&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;&amp;nbsp;&lt;/p&gt;&lt;/strong&gt;&lt;/strong&gt; &lt;p&gt;&lt;font color="white"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-6215154937854055869?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/6215154937854055869/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2010/02/using-google-adwords-on-content.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/6215154937854055869'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/6215154937854055869'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2010/02/using-google-adwords-on-content.html' title='Using Google AdWords on Content networks, a click-fraud investigation.'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-4175540391788025495</id><published>2010-01-26T12:18:00.001Z</published><updated>2010-01-26T13:33:15.956Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPP'/><category scheme='http://www.blogger.com/atom/ns#' term='Products'/><category scheme='http://www.blogger.com/atom/ns#' term='PDF Converter'/><category scheme='http://www.blogger.com/atom/ns#' term='Workflow'/><category scheme='http://www.blogger.com/atom/ns#' term='Articles'/><title type='text'>Adding a watermark to a PDF file from a SharePoint Workflow</title><content type='html'>&lt;p&gt;We get a great amount of interest from our existing &lt;a href="http://www.muhimbi.com/Products/PDF-Converter-for-SharePoint/summary.aspx"&gt;PDF Converter&lt;/a&gt; customers for the &lt;a href="http://www.muhimbi.com/Products/Workflow-Power-Pack-for-SharePoint/summary.aspx"&gt;Workflow Power Pack for SharePoint&lt;/a&gt;. I am not really surprised as there is a lot of of synergy between the two. &lt;/p&gt; &lt;p&gt;Last week I described &lt;a href="http://www.muhimbi.com/blog/2010/01/configure-pdf-security-from-sharepoint.html"&gt;how to configure PDF Security settings from a SharePoint workflow&lt;/a&gt;. This time I’ll describe another common request; adding a watermark to a PDF File.&lt;/p&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2010/01/adding-watermark-to-pdf-file-from.html';&lt;/script&gt;&lt;span style="margin-top: 3px; float: left; margin-right: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;A quick introduction for those not familiar with the product: &lt;em&gt;The Muhimbi Workflow Power Pack for SharePoint allows custom C# or VB.NET code to be embedded in SharePoint Designer Workflows without the need to resort to complex Visual Studio based workflows, the development of bespoke Workflow Activities or long development cycles.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;The solution presented below executes a workflow whenever a PDF file is added or updated. As part of the workflow it loads &lt;em&gt;portrait&lt;/em&gt; and &lt;em&gt;landscape&lt;/em&gt; based watermarks and applies the relevant template to each page of the document. The workflow author can specify if the watermark goes in the foreground or the background, the SharePoint location of the watermarks as well as the level of transparency. As the code is well documented it is easy to make further changes and customisations, e.g. the PDF file that needs to be watermarked may not be the file the workflow is acting on.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="WatermarkedPages" border="0" alt="WatermarkedPages" src="http://lh6.ggpht.com/_IgJp5HQ80aU/S17deGrrWmI/AAAAAAAAALg/hGVRukJdFYc/WatermarkedPages%5B6%5D.jpg?imgmax=800" width="690" height="311"&gt; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;br&gt;Create the workflow as follows:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;&lt;a href="http://www.muhimbi.com/Products/Workflow-Power-Pack-for-SharePoint.aspx"&gt;Download and install the Muhimbi Workflow Power Pack for SharePoint&lt;/a&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;a href="http://www.muhimbi.com/Products/PDF-Converter-for-SharePoint.aspx"&gt;Download and install the Muhimbi PDF Converter for SharePoint&lt;/a&gt;. &lt;br&gt;&lt;strong&gt;&lt;em&gt;&lt;font color="#ff0000"&gt;Note that you need version 3.1.2.18 or newer, older versions do not allow watermarking&lt;/font&gt;&lt;/em&gt;&lt;/strong&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;a href="http://www.muhimbi.com/Images---Files/WorkflowPowerPack/Muhimbi-Workflow-Watermarking.aspx"&gt;Download this article’s source code and sample watermarks&lt;/a&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;We need to be able to access functionality in the &lt;em&gt;Muhimbi.SharePoint.DocumentConverter.PDF&lt;/em&gt; and &lt;em&gt;System.Drawing&lt;/em&gt; assemblies. Add these references to the relevant Web Application using the &lt;i&gt;Workflow Power Pack Central Administration screens&lt;/i&gt; as described in the &lt;a href="http://www.muhimbi.com/support/documentation/Workflow-Power-Pack/Administration-Guide.aspx"&gt;Administration Guide&lt;/a&gt;. Make sure to place each reference on a new line.&lt;br&gt;&amp;nbsp;&amp;nbsp; &lt;li&gt;Make sure you have the appropriate privileges to create workflows on a site collection.&lt;br&gt;&amp;nbsp; &lt;li&gt;Create a new workflow using SharePoint Designer.&lt;br&gt;&amp;nbsp; &lt;li&gt;On the Workflow definition screen associate the workflow with the &lt;em&gt;Shared Documents&lt;/em&gt; library, tick the boxes next to both ‘&lt;em&gt;Automatically start….&lt;/em&gt;’ options and proceed to the next screen.&lt;br&gt;&amp;nbsp; &lt;li&gt;We only want to act on files of type PDF. Although we could have put this validation in the code, in this example we use a workflow condition for it so add a &lt;em&gt;Compare Any Data Source&lt;/em&gt; condition and:&lt;br&gt;&amp;nbsp;&lt;br&gt;a.&amp;nbsp; Click on the first &lt;em&gt;value&lt;/em&gt; followed by the &lt;em&gt;display data binding&lt;/em&gt; (fx) button. &lt;br&gt;b.&amp;nbsp; Select &lt;em&gt;Current Item&lt;/em&gt; as the Source and select &lt;em&gt;File Type&lt;/em&gt; in the Field. Click the OK button to continue. &lt;br&gt;d.&amp;nbsp; Click on the second &lt;em&gt;value&lt;/em&gt; and enter &lt;em&gt;pdf&lt;/em&gt;. &lt;br&gt;&amp;nbsp; &lt;li&gt;Click the &lt;i&gt;Actions&lt;/i&gt; button and insert the &lt;em&gt;Execute Custom Code &lt;/em&gt;action&lt;em&gt;.&lt;br&gt;&amp;nbsp; &lt;/em&gt; &lt;li&gt;Optionally click &lt;u&gt;parameter 1&lt;/u&gt; and enter a relative or absolute destination path. Leave the parameter empty to save the watermarked file on top of the existing PDF file. For details about how paths are handled, see &lt;a href="http://www.muhimbi.com/blog/2009/11/automatically-convert-files-to-pdf.html"&gt;this post&lt;/a&gt; and search for the words ‘this url’. &lt;br&gt;&amp;nbsp; &lt;li&gt;Insert the C# based code embedded in step #3’s download (also listed below) by clicking &lt;u&gt;this code&lt;/u&gt;.&lt;br&gt;&amp;nbsp; &lt;div style="padding-bottom: 6px; padding-left: 6px; padding-right: 6px; font-family: consolas; background: black; color: white; font-size: 8pt; font-weight: bold; padding-top: 6px"&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;/*********************************************************************************************&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Muhimbi PDF Converter - Watermarking&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Copyright 2010, Muhimbi Ltd - www.muhimbi.com - All rights reserved&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; The following code shows a simple way of adding a watermark to existing PDF Files. &lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; Error and permission checking as well as other minor features have been omitted for the sake &lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; of brevity and clarity.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; Ideally PDF Conversion, applying security and watermarking is executed in the same step, see &lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; http://www.muhimbi.com/blog/2010/01/configure-pdf-security-from-sharepoint.html&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; This code requires Muhimbi’s PDF Converter and Workflow Power Pack to be installed.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;*********************************************************************************************/&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; System.Drawing;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; System.IO;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; Syncfusion.Pdf;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; Syncfusion.Pdf.Parsing;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; Syncfusion.Pdf.Graphics;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; Muhimbi.SharePoint.DocumentConverter.PDF;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SPFile spSourceDocument = MyWorkflow.Item.File;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; destinationFileName = spSourceDocument.Name;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; destinationFolderName = MyWorkflow.Parameter1 &lt;span style="color: #cc7832"&gt;as&lt;/span&gt; &lt;span style="color: #cc7832"&gt;string&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; watermarkDocumentPortraitPath = &lt;span style="color: #eb6767; font-weight: normal"&gt;@"Shared Documents/Watermarks/WatermarkA4Portrait.pdf"&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; watermarkDocumentLandscapePath = &lt;span style="color: #eb6767; font-weight: normal"&gt;@"Shared Documents/Watermarks/WatermarkA4Landscape.pdf"&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** z-order and transparency of the watermark&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;bool&lt;/span&gt; watermarkInBackground = &lt;span style="color: #cc7832"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;float&lt;/span&gt; watermarkTransparancy = &lt;span style="color: #6897bb"&gt;0.25f&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Load the document and watermarks&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;PdfLoadedDocument sourceDocument = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; PdfLoadedDocument(spSourceDocument.OpenBinary());&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SPFile spWatermarkDocumentPortrait = MyWorkflow.Web.GetFile(watermarkDocumentPortraitPath);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;PdfLoadedDocument watermarkDocumentPortrait = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; PdfLoadedDocument(&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; spWatermarkDocumentPortrait.OpenBinary());&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SPFile spWatermarkDocumentLandscape = MyWorkflow.Web.GetFile(watermarkDocumentLandscapePath);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;PdfLoadedDocument watermarkDocumentLandscape = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; PdfLoadedDocument(&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; spWatermarkDocumentLandscape.OpenBinary());&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Create the PDF Templates&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;PdfTemplate watermarkTemplatePortrait = watermarkDocumentPortrait.Pages[&lt;span style="color: #6897bb"&gt;0&lt;/span&gt;].CreateTemplate();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;PdfTemplate watermarkTemplateLandscape = watermarkDocumentLandscape.Pages[&lt;span style="color: #6897bb"&gt;0&lt;/span&gt;].CreateTemplate();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Iterate over all pages and apply watermark&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;foreach&lt;/span&gt; (PdfPageBase page &lt;span style="color: #cc7832"&gt;in&lt;/span&gt; sourceDocument.Pages)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Is the current page portrait or landscape?&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PdfTemplate watermarkTemplate = &lt;span style="color: #cc7832"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;if&lt;/span&gt; (page.Size.Width &amp;gt; page.Size.Height)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; watermarkTemplate = watermarkTemplateLandscape;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; watermarkTemplate = watermarkTemplatePortrait;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Place watermark behind or in front of text?&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;if&lt;/span&gt; (watermarkInBackground == &lt;span style="color: #cc7832"&gt;true&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PdfTemplate pageTemplate = page.CreateTemplate();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; page.Layers.Clear();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PdfGraphics g = page.Graphics;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; g.SetTransparency(watermarkTransparancy);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; g.DrawPdfTemplate(watermarkTemplate, PointF.Empty, page.Size);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; g.SetTransparency(&lt;span style="color: #6897bb"&gt;1f&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; g.DrawPdfTemplate(pageTemplate, PointF.Empty, page.Size);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PdfGraphics g = page.Graphics;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; g.SetTransparency(watermarkTransparancy);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; g.DrawPdfTemplate(watermarkTemplate, PointF.Empty, page.Size);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Construct the path and file to write the watermarked PDF file to.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;if&lt;/span&gt; (&lt;span style="color: #cc7832"&gt;string&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.IsNullOrEmpty(destinationFolderName) == &lt;/span&gt;&lt;span style="color: #cc7832"&gt;true&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; destinationFolderName = spSourceDocument.ParentFolder.Url;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SPFolder destinationFolder = Utility.GetSPFolder(destinationFolderName, MyWorkflow.Web);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; destinationFilePath = &lt;span style="color: #cc7832"&gt;string&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.Format(&lt;/span&gt;&lt;span style="color: #a5c25c"&gt;"{0}/{1}"&lt;/span&gt;, destinationFolder.Url,&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; destinationFileName);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SPWeb destinationWeb = destinationFolder.ParentWeb;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SPFile spDestinationFile = destinationWeb.GetFile(destinationFilePath);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** If a document library requires manual checkout and the file is not checked out, then &lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** check the file out before uploading.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;if&lt;/span&gt; (spDestinationFile.Exists &amp;amp;&amp;amp; spDestinationFile.Item.ParentList.ForceCheckout &amp;amp;&amp;amp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; spDestinationFile.CheckOutStatus == SPFile.SPCheckOutStatus.None)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; spDestinationFile.CheckOut();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Add the file to the site including the meta data&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; (MemoryStream watermarkedFile = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; MemoryStream())&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sourceDocument.Save(watermarkedFile);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; spDestinationFile = destinationWeb.Files.Add(destinationFilePath, watermarkedFile,&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; spSourceDocument.Item.Properties, &lt;span style="color: #cc7832"&gt;true&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Check the file back in if this script was responsible for checking it out.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;if&lt;/span&gt; (spDestinationFile.Item.ParentList.ForceCheckout == &lt;span style="color: #cc7832"&gt;true&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; spDestinationFile.CheckIn(&lt;span style="color: #a5c25c"&gt;"Auto check-in after PDF watermarking."&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;/div&gt;&amp;nbsp; &lt;li&gt;Click the &lt;i&gt;Actions&lt;/i&gt; button, select &lt;i&gt;Log to History List&lt;/i&gt;, click &lt;i&gt;&lt;u&gt;this message&lt;/u&gt;&lt;/i&gt; and enter &lt;em&gt;File watermarked&lt;/em&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;Close the Workflow Designer.&lt;br&gt;&amp;nbsp; &lt;li&gt;In the &lt;em&gt;Shared Documents&lt;/em&gt; library create a sub folder named &lt;em&gt;Watermarks&lt;/em&gt; and copy the 2 watermark files that are part of step #3’s download into it. If the watermarks are named differently or stored in a different location then update the paths in the script accordingly. Note that the sample watermarks are exactly A4 sized but they work fine on differently sized documents. &lt;br&gt;&amp;nbsp; &lt;li&gt;Update an existing PDF or add a new PDF file to your library to trigger the workflow and apply the watermarks.&lt;br&gt;&amp;nbsp; &lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="WaterMarkScript" border="0" alt="WaterMarkScript" src="http://lh6.ggpht.com/_IgJp5HQ80aU/S17dejBVI3I/AAAAAAAAALk/Nlmv78dC8iw/WaterMarkScript%5B5%5D.jpg?imgmax=800" width="575" height="304"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Naturally this is just a simple example. Feel free to play around with the code, change which parameters are passed into the workflow, modify where watermarked files are written to or add dynamic text as a watermark. Leave a comment below if you are trying to do anything specific.&lt;/p&gt;
&lt;p&gt;&lt;font color="white"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-4175540391788025495?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/4175540391788025495/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2010/01/adding-watermark-to-pdf-file-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/4175540391788025495'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/4175540391788025495'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2010/01/adding-watermark-to-pdf-file-from.html' title='Adding a watermark to a PDF file from a SharePoint Workflow'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-8447876011490005655</id><published>2010-01-22T12:03:00.001Z</published><updated>2010-01-22T12:17:58.612Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='MuSH'/><category scheme='http://www.blogger.com/atom/ns#' term='WPP'/><category scheme='http://www.blogger.com/atom/ns#' term='Products'/><category scheme='http://www.blogger.com/atom/ns#' term='Audit'/><category scheme='http://www.blogger.com/atom/ns#' term='Partnering'/><category scheme='http://www.blogger.com/atom/ns#' term='PDF Converter'/><title type='text'>How we license our products – Make sure your organisation is compliant</title><content type='html'>&lt;p&gt;&lt;img style="border-right-width: 0px; margin: 0px 10px 5px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="License" border="0" alt="License" align="right" src="http://lh5.ggpht.com/_IgJp5HQ80aU/S1mT96aI2yI/AAAAAAAAALU/YFmawTwb4l4/License5.jpg?imgmax=800" width="150" height="212"&gt;Any organisation that deals with computer software, free or otherwise, must be aware of the License Agreement that comes with a software product. &lt;em&gt;How many computers can the software be used on&lt;/em&gt;, &lt;em&gt;by how many users&lt;/em&gt; and &lt;em&gt;how long is the license valid&lt;/em&gt; are only some of the questions that need to be answered.&lt;/p&gt; &lt;p&gt;We have invested quite some time in making &lt;a href="http://www.muhimbi.com/Software-License-Agreement.aspx"&gt;our Software License Agreement&lt;/a&gt; readable for people without a legal background. However, it is difficult to cover all grounds using plain English. &lt;/p&gt; &lt;p&gt;This post attempts to explain the key elements of our Software Agreement in plain English. Note that this is only a summary and does not replace the actual License Agreement.&lt;/p&gt; &lt;p&gt;The following topics are discussed in this post:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#summary"&gt;Summary of available licenses&lt;/a&gt;  &lt;li&gt;&lt;a href="#renewing"&gt;Renewing Licenses / Support licenses&lt;/a&gt;  &lt;li&gt;&lt;a href="#environments"&gt;What servers / environments do you need a license for&lt;/a&gt;  &lt;li&gt;&lt;a href="#nonSharePoint"&gt;Licensing requirements for non SharePoint based deployments&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;ul&gt;&amp;nbsp;&lt;/ul&gt; &lt;p&gt;&lt;a name="summary"&gt;&lt;/a&gt;&lt;strong&gt;Summary of available licenses&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;We use a graded licensing system to match your budget and exact needs. The following license types are available: &lt;br&gt;&amp;nbsp;&lt;br&gt; &lt;p&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="License-Matrix" border="0" alt="License-Matrix" src="http://lh6.ggpht.com/_IgJp5HQ80aU/S1mT-dFPZzI/AAAAAAAAALY/fHplUb__HiI/LicenseMatrix7.jpg?imgmax=800" width="694" height="332"&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;Free evaluation version:&lt;/strong&gt; If you install the software without a license then you are using the evaluation version. The software is fully functional without any time limits, but an evaluation message will be displayed on most screens and in any generated document. You are not permitted to use any evaluation software in your production environment. Support is provided using any of the means in the &lt;a href="http://www.muhimbi.com/support.aspx"&gt;Support area&lt;/a&gt; on our site. &lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;strong&gt;Web Application License: &lt;/strong&gt;This license is sold at a considerable discount to allow small organisations with just a single SharePoint server and Web Application to get started with our software. If you have a single SharePoint server then you can use this license on a single Web Application on as many Site Collections as you like. &lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;strong&gt;Web Farm License:&lt;/strong&gt; If you have more than one server in your SharePoint farm or want to use our software on multiple Web Applications then you may want to consider this license. If you want to use our software on multiple farms or if your farm is spread over multiple geographical locations then you need either a Site or OEM license as described below.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;strong&gt;Site License:&lt;/strong&gt; If you have multiple separate SharePoint Farms, for example when you are a hosting company, then this license may be the best option as it allows the software to be used on an unlimited number of separate SharePoint farms at a single location.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;strong&gt;OEM License:&lt;/strong&gt; If your SharePoint Farm or Farms spreads multiple physical locations, e.g. across a data centre, Disaster recovery site and or local branch offices OR if you want to bundle our Software as part of your own solution then the OEM Subscription is most likely the best option. Please read the details in the Software License Agreement if you want to bundle our software with your own solution. Note that you are not allowed to use our Products to develop derived works that offer similar functionality as the Product or expose the features of the Product for use by an unlicensed third party unless agreed with Muhimbi.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;strong&gt;OEM License + Source Code:&lt;/strong&gt; If you need all the benefits of the OEM License and / or you need access to the source code to make modifications specific to your organisation, then this license type is the best option. Note that we do not provide support for our software once changes have been made to the source code. Please read the details in the Software License Agreement if you want to bundle our software with your own solution. Note that you are not allowed to use our Products to develop derived works that offer similar functionality as the Product or expose the features of the Product for use by an unlicensed third party unless agreed with Muhimbi.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;a name="renewing"&gt;&lt;/a&gt;&lt;strong&gt;Renewing Licenses / Support licenses&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Independent of the type of license purchased, you automatically receive a 1 year support license, which entitles you to free updates and access to our support desk using any of the means listed on the &lt;a href="http://www.muhimbi.com/contact.aspx"&gt;Contact Us&lt;/a&gt; page.&lt;/p&gt; &lt;p&gt;After the support license has expired your software will continue to work, but you can no longer download new versions released after the expiry of the license. You can renew your support license for 30% of the current retail price, which is not necessarily the price you originally bought the product for, although they may be the same.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;a name="environments"&gt;&lt;strong&gt;What servers / environments do you need a license for&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Some vendors charge extra license fees for Development or Test environments, which - quite frankly - we find a questionable practice. Having said that, some organisations run the same software in multiple environments. The most common environments are summarised below with an explanation about any extra licenses needed.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;Development:&lt;/strong&gt; This environment is commonly used by Software or SharePoint developers to create or update solutions using tools such as Visual Studio and SharePoint Designer. Providing our software is used for development purposes only and not used for any production use then you don’t need a separate license for this environment. Examples of Production use in a Development environment is running our PDF Converter on the Development Team’s SharePoint Server if this server is located in the Development subnet and used for production use, e.g. storing documents for the development projects.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;strong&gt;Systems Test:&lt;/strong&gt; Once development on a software project has finished, the solution is commonly installed and tested in a clean test environment that resembles the Production environment. Providing this environment is not used for Production use, it rarely is, you do not need an extra license.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;strong&gt;User Acceptance Test:&lt;/strong&gt; Once the development team has finished development, the end-users usually test the solution as well to see if it matches the requirements and functions as expected. Some organisations use the Systems Test environment for this, but other organisations have a separate UAT environment. Providing this environment is not used for Production use, it rarely is, you do not need an extra license.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;strong&gt;Support:&lt;/strong&gt; Some organisations run an identical copy of their Production environment in a so called &lt;em&gt;Support environment&lt;/em&gt;. Quite often this environment runs very recent data based on backups taken the day before. Support staff can assist users and troubleshoot problems on a relatively up to date copy of the system without impacting the data in the Production system. From a licensing perspective this is a grey area as this environment is sometimes used for Production use. For example, if a Production user requests assistance with the conversion of a PDF file and this conversion is then carried out by a member of the support team in the Support environment and the resulting file is transferred to the user then this is considered Production use and you need a license for this environment. &lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;strong&gt;Staging:&lt;/strong&gt; Depending on the kind of solutions in place, an organisation or team may need a staging environment. Staging environments are commonly used, but not limited to, content management based solutions to prepare content for an Intranet or public web site. Providing this environment runs on a farm separate from the Production farm you need a license for this environment:&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;strong&gt;Production:&lt;/strong&gt; Production environments always need a license.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;strong&gt;Disaster Recovery:&lt;/strong&gt; Many of the larger organisation mirror their production environment in an off-site Disaster Recovery Centre. From a licensing perspective we consider Disaster Recovery Centres to be Production environments, even if disaster never strikes and the environment is never used.&lt;/li&gt;&lt;/ul&gt; &lt;ul&gt;In summary, if you need a license for more than one environment, get a Site License if all servers are based in one physical location. Purchase an OEM License if your servers are spread over multiple locations.&lt;/ul&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;a name="nonSharePoint"&gt;&lt;/a&gt;&lt;strong&gt;Licensing requirements for non SharePoint based deployments&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Our products mainly focus on use from a SharePoint environment. However, some products can also be used from non SharePoint environments as well. For example, our PDF Conversion Service can &lt;a href="http://www.muhimbi.com/blog/2009/12/converting-office-files-to-pdf-format.html"&gt;run as a standalone service&lt;/a&gt; and be accessed from any application that supports Web Services. &lt;/p&gt; &lt;p&gt;The licenses are largely the same, with the exception of the Web Application License, which is only available for SharePoint based environments. &lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;Web Farm License:&lt;/strong&gt; Get this license if you want to access our software from a single solution on an unlimited number of servers located at a single location, using an unlimited number of developers and end-users.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;strong&gt;Site License:&lt;/strong&gt; If you intend to access our software from multiple solutions located on servers at the same site, then get this license.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;strong&gt;OEM License:&lt;/strong&gt; If you want to access our software from servers spread across more than one physical location then get this license.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;strong&gt;OEM License + Source Code:&lt;/strong&gt; If you need all the benefits of the OEM License and / or you need access to the source code to make modifications specific to your organisation, then this license type is the best option. Note that we do not provide support for our software once changes have been made to the source code. Please read the details in the Software License Agreement if you want to bundle our software with your own solution. Note that you are not allowed to use our Products to develop derived works that offer similar functionality as the Product or expose the features of the Product for use by an unlicensed third party unless agreed with Muhimbi.&lt;br&gt;&amp;nbsp;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;I realise this post is almost longer than the License Agreement is is trying to explain, but I hope it clarifies our licensing position. If you have any further questions then please check out the following sources or contact us at &lt;a href="mailto:licensing@muhimbi.com"&gt;licensing@muhimbi.com&lt;/a&gt;.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://www.muhimbi.com/Software-License-Agreement.aspx"&gt;License Agreement&lt;/a&gt;  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/faqs.aspx#Licensing"&gt;Licensing FAQ&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;font color="white"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-8447876011490005655?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/8447876011490005655/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2010/01/how-we-license-our-products-make-sure.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/8447876011490005655'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/8447876011490005655'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2010/01/how-we-license-our-products-make-sure.html' title='How we license our products – Make sure your organisation is compliant'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-3011791106504945081</id><published>2010-01-20T16:10:00.001Z</published><updated>2010-01-20T16:14:00.947Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='News'/><category scheme='http://www.blogger.com/atom/ns#' term='Products'/><category scheme='http://www.blogger.com/atom/ns#' term='PDF Converter'/><title type='text'>PDF Converter for SharePoint 3.1 – With new Visio and improved InfoPath Conversion</title><content type='html'>&lt;img style="border-right-width: 0px; margin: 5px 0px 5px 5px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="OfficeIcons5" border="0" alt="OfficeIcons5" align="right" src="http://lh4.ggpht.com/_IgJp5HQ80aU/S1crBPxsU2I/AAAAAAAAALM/U-BwWOKDSgU/OfficeIcons5%5B9%5D.jpg?imgmax=800" width="139" height="200"&gt;  &lt;p&gt;It has been exactly 2 months since we released a &lt;a href="http://www.muhimbi.com/blog/2009/11/pdf-converter-30-for-sharepoint-convert.html"&gt;completely overhauled&lt;/a&gt; version of our &lt;a href="http://www.muhimbi.com/Products/PDF-Converter-for-SharePoint/Summary.aspx"&gt;PDF Converter for SharePoint&lt;/a&gt;. We are seeing a considerable increase in downloads as well as purchases, which means one thing….. increased customer feedback!&lt;/p&gt; &lt;p&gt;The new version of the software resolves the most urgent issues, removes a number of pain points that should make configuration for certain scenarios a lot easier, improves support for the more complex InfoPath forms and adds support for converting MS-Visio files as well as a number of related vector formats (vsd, vdx, svg, svgz, dwg, dxf).&lt;/p&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2010/01/pdf-converter-for-sharepoint-31-with.html';&lt;/script&gt;&lt;span style="margin-top: 3px; float: left; margin-right: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;For those not familiar with the product, the PDF Converter for SharePoint is a lightweight solution (4MB download) that allows end-users to convert common document types to PDF format from within SharePoint without the need to install any client side software or Adobe Acrobat. It integrates at a deep level with SharePoint and leverages facilities such as the Audit log, localisation, security and tracing. It runs on both WSS 3 as well as MOSS and is available in English, German, Dutch, French and Japanese. For detailed information check out the &lt;a href="http://www.muhimbi.com/Products/PDF-Converter-for-SharePoint.aspx"&gt;product page&lt;/a&gt; as well as the following blog postings:&lt;/p&gt; &lt;ul&gt; &lt;li style="margin-bottom: 2pt"&gt;&lt;a href="http://www.muhimbi.com/blog/2009/04/using-pdf-converter-from-sharepoint.html"&gt;Using the PDF Converter from a SharePoint workflow&lt;/a&gt;.  &lt;li style="margin-bottom: 2pt"&gt;&lt;a href="http://www.muhimbi.com/blog/2010/01/configure-pdf-security-from-sharepoint.html"&gt;Configure PDF Security from a SharePoint Workflow&lt;/a&gt;.  &lt;li style="margin-bottom: 2pt"&gt;&lt;a href="http://www.muhimbi.com/blog/2009/09/inserting-sharepoint-list-data-into-pdf.html"&gt;Inserting SharePoint List data into a PDF document using a workflow&lt;/a&gt;.  &lt;li style="margin-bottom: 2pt"&gt;&lt;a href="http://www.muhimbi.com/blog/2009/10/using-pdf-converter-for-sharepoint-from.html"&gt;Using the PDF Converter for SharePoint from your own code&lt;/a&gt;.  &lt;li style="margin-bottom: 2pt"&gt;&lt;a href="http://www.muhimbi.com/blog/2009/11/automatically-convert-files-to-pdf.html"&gt;Automatically convert files to PDF using an e-mail enabled SharePoint Document Library&lt;/a&gt;.  &lt;li style="margin-bottom: 2pt"&gt;&lt;a href="http://www.muhimbi.com/blog/2009/12/batch-print-infopath-forms-using-pdf.html"&gt;Batch print InfoPath Forms using the PDF Converter for SharePoint&lt;/a&gt;.  &lt;li style="margin-bottom: 2pt"&gt;&lt;a href="http://www.muhimbi.com/blog/2009/12/converting-office-files-to-pdf-format.html"&gt;Converting Office files to PDF Format using a Web Services based interface&lt;/a&gt;.  &lt;li style="margin-bottom: 2pt"&gt;&lt;a href="http://www.muhimbi.com/blog/2009/11/troubleshooting-steps-for-pdf-converter.html"&gt;Troubleshooting steps for the PDF Converter for SharePoint&lt;/a&gt;.  &lt;li style="margin-bottom: 2pt"&gt;&lt;a href="http://www.muhimbi.com/blog/2009/11/troubleshooting-infopath-to-pdf.html"&gt;Troubleshooting InfoPath to PDF Conversion / Document Converter Architecture&lt;/a&gt;. &lt;br&gt;&amp;nbsp;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="workflow26" border="0" alt="workflow26" src="http://lh5.ggpht.com/_IgJp5HQ80aU/S1crBpuvVNI/AAAAAAAAALQ/WZxkgnGsIzU/workflow26%5B5%5D.jpg?imgmax=800" width="680" height="193"&gt;  &lt;div style="position: relative; text-align: center; font-size: 8pt; top: -20px"&gt;&lt;i&gt;Convert files using the User Interface or an automated Workflow&lt;/i&gt;&lt;/div&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;br&gt;The main changes in version 3.1 are as follows:&lt;/p&gt; &lt;table border="0" cellspacing="0" cellpadding="2" width="700"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" width="31"&gt;&lt;font size="2"&gt;754&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" width="667"&gt;&lt;font size="2"&gt;Fixed: InfoPath data files without a shared template location cannot be converted.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top"&gt;&lt;font size="2"&gt;751&lt;/font&gt;&lt;/td&gt; &lt;td valign="top"&gt;&lt;font size="2"&gt;New: Added support for conversion of Visio and other vector based file types, including AutoCad.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top"&gt;&lt;font size="2"&gt;671&lt;/font&gt;&lt;/td&gt; &lt;td valign="top"&gt;&lt;font size="2"&gt;Improved: Support for ‘difficult’ InfoPath documents containing Full Trust .net code.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top"&gt;&lt;font size="2"&gt;739&lt;/font&gt;&lt;/td&gt; &lt;td valign="top"&gt;&lt;font size="2"&gt;Improved: Remove manual configuration steps for systems that store .dotx templates in SharePoint.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top"&gt;&lt;font size="2"&gt;740&lt;/font&gt;&lt;/td&gt; &lt;td valign="top"&gt;&lt;font size="2"&gt;Improved: &lt;font size="2"&gt;Remove manual configuration steps for documents that contain Document Information Panels.&lt;/font&gt; &lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top"&gt;&lt;font size="2"&gt;&lt;font size="2"&gt;495&lt;/font&gt;&lt;/font&gt;&lt;/td&gt; &lt;td valign="top"&gt;&lt;font size="2"&gt;Fixed: Using the Browse button to navigate to the root of a renamed document library doesn't work.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top"&gt;&lt;font size="2"&gt;289&lt;/font&gt;&lt;/td&gt; &lt;td valign="top"&gt;&lt;font size="2"&gt;Fixed: Cannot select folder in Tree picker when the file name is empty.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top"&gt;&lt;font size="2"&gt;&lt;font size="2"&gt;736&lt;/font&gt;&lt;/font&gt;&lt;/td&gt; &lt;td valign="top"&gt;&lt;font size="2"&gt;Fixed: Meta data of type ‘Date’ is not copied over correctly for Office 2007 based files.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;br&gt;For more information check out the following resources:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://www.muhimbi.com/Products/PDF-Converter-for-SharePoint.aspx"&gt;Product Page&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/faqs.aspx"&gt;FAQ&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/documentation/PDF-Converter-for-SharePoint/Release-Notes.aspx"&gt;Release Notes&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/documentation/PDF-Converter-for-SharePoint/Administration-Guide.aspx"&gt;Administration Guide&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/documentation/PDF-Converter-for-SharePoint/User-Guide.aspx"&gt;User Guide&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/documentation/PDF-Converter-for-SharePoint/Screenshots.aspx"&gt;Screenshots&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/forum.aspx"&gt;Message Board&lt;/a&gt;. &lt;/li&gt;&lt;/ul&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2010/01/pdf-converter-for-sharepoint-31-with.html';&lt;/script&gt;&lt;span style="margin-top: 11px; float: right; margin-left: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;&amp;nbsp;&lt;br&gt;As always, feel free to &lt;a href="http://www.muhimbi.com/contact.aspx"&gt;contact us using Twitter, our Blog, regular email&lt;/a&gt; or &lt;a href="http://eepurl.com/b6A7"&gt;subscribe to our newsletter&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p align="center"&gt;&lt;a href="http://www.muhimbi.com/Products/PDF-Converter-for-SharePoint/Free-Trial.aspx"&gt;Download your free trial here&lt;/a&gt; (4MB). &lt;br&gt;&lt;font color="#ffffff"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-3011791106504945081?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/3011791106504945081/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2010/01/pdf-converter-for-sharepoint-31-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/3011791106504945081'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/3011791106504945081'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2010/01/pdf-converter-for-sharepoint-31-with.html' title='PDF Converter for SharePoint 3.1 – With new Visio and improved InfoPath Conversion'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-7056480293120352225</id><published>2010-01-15T16:35:00.001Z</published><updated>2010-01-20T16:58:13.853Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPP'/><category scheme='http://www.blogger.com/atom/ns#' term='Products'/><category scheme='http://www.blogger.com/atom/ns#' term='PDF Converter'/><category scheme='http://www.blogger.com/atom/ns#' term='Workflow'/><category scheme='http://www.blogger.com/atom/ns#' term='Articles'/><title type='text'>Configure PDF Security from a SharePoint Workflow</title><content type='html'>&lt;p&gt;&lt;img style="border-right-width: 0px; margin: 5px 0px 5px 5px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="combination_lock" border="0" alt="combination_lock" align="right" src="http://lh3.ggpht.com/_IgJp5HQ80aU/S1CZSz8LSzI/AAAAAAAAALA/D6Yk82oAGcY/combination_lock%5B5%5D.jpg?imgmax=800" width="140" height="149"&gt; Our &lt;a href="http://www.muhimbi.com/Products/PDF-Converter-for-SharePoint/summary.aspx"&gt;PDF Converter for SharePoint&lt;/a&gt; is getting &lt;a href="http://www.muhimbi.com/blog/2010/01/pdf-converter-for-sharepoint-first.html"&gt;great reviews&lt;/a&gt;, but naturally we cannot please everyone, or at least not yet. One of the requests we get from time to time is to add support for the ability to specify PDF Security settings (Open Password, Owner Password, Block Print, Block Copy etc). &lt;/p&gt; &lt;p&gt;The thing is, our underlying engine and &lt;a href="http://www.muhimbi.com/blog/2009/12/converting-office-files-to-pdf-format.html"&gt;Web Service interface&lt;/a&gt; already support this functionality. However, the user interface and workflow action have not yet been updated. In this article we describe how to access this ‘hidden’ functionality from a workflow using the &lt;a href="http://www.muhimbi.com/Products/Workflow-Power-Pack-for-SharePoint.aspx"&gt;Workflow Power Pack&lt;/a&gt;. &lt;/p&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2010/01/configure-pdf-security-from-sharepoint.html';&lt;/script&gt;&lt;span style="margin-top: 3px; float: left; margin-right: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;A quick introduction for those not familiar with the product: &lt;em&gt;The Muhimbi Workflow Power Pack for SharePoint allows custom C# or VB.NET code to be embedded in SharePoint Designer Workflows without the need to resort to complex Visual Studio based workflows, the development of bespoke Workflow Activities or long development cycles.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;The solution presented below automatically converts any updated or newly created files to PDF format and applies the &lt;em&gt;DisablePrint&lt;/em&gt; and &lt;em&gt;DisableContentCopy&lt;/em&gt; security flags to the file. As the code is well documented it is easy to make further changes and customisations.&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_IgJp5HQ80aU/S1CZTDJCa8I/AAAAAAAAALE/tf-7uaydXbc/image%5B14%5D.png?imgmax=800" width="383" height="168"&gt; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;br&gt;Create the workflow as follows:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;&lt;a href="http://www.muhimbi.com/Products/Workflow-Power-Pack-for-SharePoint.aspx"&gt;Download and install the Muhimbi Workflow Power Pack for SharePoint&lt;/a&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;a href="http://www.muhimbi.com/Products/PDF-Converter-for-SharePoint.aspx"&gt;Download and install the Muhimbi PDF Converter for SharePoint&lt;/a&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;We need to be able to access functionality in the &lt;em&gt;Muhimbi.SharePoint.DocumentConverter.PDF&lt;/em&gt;, &lt;em&gt;System.ServiceModel&lt;/em&gt; and &lt;em&gt;System.Runtime.Serialization&lt;/em&gt; assemblies. Add these references to the relevant Web Application using the &lt;i&gt;Workflow Power Pack Central Administration screens&lt;/i&gt; as described in the &lt;a href="http://www.muhimbi.com/support/documentation/Workflow-Power-Pack/Administration-Guide.aspx"&gt;Administration Guide&lt;/a&gt;. Make sure to place each reference on a new line.&lt;br&gt;&amp;nbsp;&amp;nbsp; &lt;li&gt;Make sure you have the appropriate privileges to create workflows on a site collection.&lt;br&gt;&amp;nbsp; &lt;li&gt;Create a new workflow using SharePoint Designer.&lt;br&gt;&amp;nbsp; &lt;li&gt;On the Workflow definition screen associate the workflow with the library of your choice, tick the boxes next to both ‘&lt;em&gt;Automatically start….&lt;/em&gt;’ options and proceed to the next screen.&lt;br&gt;&amp;nbsp; &lt;li&gt;To prevent the code from acting on files that are already in PDF format, add a &lt;em&gt;Compare Any Data Source&lt;/em&gt; condition and:&lt;br&gt;&amp;nbsp;&lt;br&gt;a.&amp;nbsp; Click on the first &lt;em&gt;value&lt;/em&gt; followed by the &lt;em&gt;display data binding&lt;/em&gt; (fx) button. &lt;br&gt;b.&amp;nbsp; Select &lt;em&gt;Current Item&lt;/em&gt; as the Source and select &lt;em&gt;File Type&lt;/em&gt; in the Field. Click the OK button to continue. &lt;br&gt;c.&amp;nbsp; Click &lt;em&gt;equals&lt;/em&gt; and change it to &lt;em&gt;not equals&lt;/em&gt;. &lt;br&gt;d.&amp;nbsp; Click on the second &lt;em&gt;value&lt;/em&gt; and enter &lt;em&gt;pdf&lt;/em&gt;. &lt;br&gt;&amp;nbsp; &lt;li&gt;Click the &lt;i&gt;Actions&lt;/i&gt; button and insert the &lt;em&gt;Execute Custom Code &lt;/em&gt;action&lt;em&gt;.&lt;br&gt;&amp;nbsp; &lt;/em&gt; &lt;li&gt;Click &lt;u&gt;parameter 1&lt;/u&gt; and optionally enter a relative or absolute destination path (For details see &lt;a href="http://www.muhimbi.com/blog/2009/11/automatically-convert-files-to-pdf.html"&gt;this post&lt;/a&gt; and search for the words ‘this url’). Leave the parameter empty to write the PDF file to the same directory as the source file.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;a href="http://www.muhimbi.com/Images---Files/WorkflowPowerPack/WPP-PDF-Conversion.aspx"&gt;Download the source code&lt;/a&gt; or insert the C# based code listed below by clicking &lt;u&gt;this code&lt;/u&gt;.&lt;br&gt;&amp;nbsp; &lt;div style="padding-bottom: 8px; padding-left: 8px; padding-right: 8px; font-family: consolas; background: black; color: white; font-size: 8pt; font-weight: bold; padding-top: 8px"&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;/********************************************************************************************&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Muhimbi PDF Converter&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Copyright 2010, Muhimbi Ltd - www.muhimbi.com - All rights reserved&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; The following code is a simplification of the code that is normally executed by the Muhimbi &lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; PDF Converter Workflow Action. Error and permission checking as well as other minor features&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; have been omitted for the sake of brevity and clarity.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; This code allows more control over the PDF Conversion process compared to what is possible &lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; with the Out-Of-The-Box action, for example: PDF Security Options, Use of PDF/A, Quality, &lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; Enable Macros and the ability to specify a password to open a source file.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; This code requires Muhimbi’s PDF Converter and Workflow Power Pack to be installed.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; For details about the Web Services interface see:&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt; http://www.muhimbi.com/blog/2009/12/converting-office-files-to-pdf-format.html&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;********************************************************************************************/&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; Muhimbi.SharePoint.DocumentConverter.PDF;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; Muhimbi.SharePoint.DocumentConverter.PDF.WebServiceClient;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; System.Collections;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Set all variables required for the conversion of the file.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SPFile sourceFile = MyWorkflow.Item.File;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Specify an empty string or null to use the same directory as the source file. &lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Alternatively specify an absolute or relative (to the web) path, e.g. &lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** subsite1/Shared Documents/PDF&amp;nbsp; or /sites/HumanResources/subsite1/Shared Documents/PDF&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; destinationFolderName&amp;nbsp;&amp;nbsp; = MyWorkflow.Parameter1 &lt;span style="color: #cc7832"&gt;as&lt;/span&gt; &lt;span style="color: #cc7832"&gt;string&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; destinationFileName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = Utility.ExtractFileName(sourceFile.Name) + &lt;span style="color: #a5c25c"&gt;".pdf"&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; openPassword&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = &lt;span style="color: #a5c25c"&gt;""&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ownerPassword&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = &lt;span style="color: #a5c25c"&gt;"A Nice And Strong Password!"&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SecurityOptions securityOptions&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = SecurityOptions.DisablePrint | &lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SecurityOptions.DisableContentCopy;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;bool&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; copyMetadata&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = &lt;span style="color: #cc7832"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Get a reference to the PDF Converter web service.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;DocumentConverterServiceClient client&amp;nbsp;&amp;nbsp; = WebServiceConverterHelper.OpenService();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;//** Set the various open options&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;OpenOptions openOptions&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; OpenOptions();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;openOptions.Password&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = &lt;span style="color: #a5c25c"&gt;""&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;openOptions.OriginalFileName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = sourceFile.Name;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;openOptions.FileExtension&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = Utility.ExtractFileExtension(sourceFile.Name);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;openOptions.AllowMacros&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = MacroSecurityOption.None;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;openOptions.RefreshContent&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = &lt;span style="color: #cc7832"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;//** Specify the various security settings&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;ConversionSettings conversionSettings&amp;nbsp;&amp;nbsp; = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; ConversionSettings();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;conversionSettings.Fidelity&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = ConversionFidelities.Full;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;conversionSettings.Format&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = OutputFormat.PDF;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;conversionSettings.Quality&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = ConversionQuality.OptimizeForPrint;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;conversionSettings.Range&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = ConversionRange.VisibleDocuments;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;conversionSettings.StartPage&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = &lt;span style="color: #6897bb"&gt;0&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;conversionSettings.EndPage&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = &lt;span style="color: #6897bb"&gt;0&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;conversionSettings.GenerateBookmarks&amp;nbsp;&amp;nbsp;&amp;nbsp; = BookmarkGenerationOption.Automatic;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;conversionSettings.PDFProfile&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = PDFProfile.PDF_1_5;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Specify either an Open or Owner Password in order to activate the security Options&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;conversionSettings.OpenPassword&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = openPassword;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;conversionSettings.OwnerPassword&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = ownerPassword;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;conversionSettings.SecurityOptions&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = securityOptions;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Read the content of the source file&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;byte&lt;/span&gt;[] sourceFileArray = sourceFile.OpenBinary();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Carry out the actual conversion to PDF&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;byte&lt;/span&gt;[] convertedFile = client.Convert(sourceFileArray, openOptions, conversionSettings);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Construct the path and file to write the PDF file to.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;if&lt;/span&gt; (&lt;span style="color: #cc7832"&gt;string&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.IsNullOrEmpty(destinationFolderName) == &lt;/span&gt;&lt;span style="color: #cc7832"&gt;true&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; destinationFolderName = sourceFile.ParentFolder.Url;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SPFolder destinationFolder = Utility.GetSPFolder(destinationFolderName, MyWorkflow.Web);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; destinationFilePath = &lt;span style="color: #cc7832"&gt;string&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.Format(&lt;/span&gt;&lt;span style="color: #a5c25c"&gt;"{0}/{1}"&lt;/span&gt;, destinationFolder.Url, &lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; destinationFileName);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SPWeb destinationWeb = destinationFolder.ParentWeb;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SPFile spDestinationFile = destinationWeb.GetFile(destinationFilePath);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** If a document library requires manual checkout and the file is not checked out, then &lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** check the file out before uploading.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;if&lt;/span&gt; (spDestinationFile.Exists &amp;amp;&amp;amp; spDestinationFile.Item.ParentList.ForceCheckout &amp;amp;&amp;amp; &lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; spDestinationFile.CheckOutStatus == SPFile.SPCheckOutStatus.None)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; spDestinationFile.CheckOut();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Copy metadata, if requested.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;if&lt;/span&gt; (copyMetadata == &lt;span style="color: #cc7832"&gt;true&lt;/span&gt; &amp;amp;&amp;amp; &lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sourceFile.Name.EndsWith(&lt;span style="color: #a5c25c"&gt;"x"&lt;/span&gt;, &lt;span style="color: #6897bb"&gt;StringComparison&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.InvariantCultureIgnoreCase) == &lt;/span&gt;&lt;span style="color: #cc7832"&gt;false&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Pre office 2007 formats (without the trailing x) are treated differently &lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** from the office 2007 formats when it comes to copying meta data.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Hashtable metadata = sourceFile.Item.Properties;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Add the file to the site including the meta data&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; spDestinationFile = destinationWeb.Files.Add(destinationFilePath, convertedFile, &lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; metadata, &lt;span style="color: #cc7832"&gt;true&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;else&lt;/span&gt; &lt;span style="color: #cc7832"&gt;if&lt;/span&gt; (copyMetadata == &lt;span style="color: #cc7832"&gt;true&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Add the file to the site.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; spDestinationFile = destinationWeb.Files.Add(destinationFilePath, &lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; convertedFile, &lt;span style="color: #cc7832"&gt;null&lt;/span&gt;, &lt;span style="color: #cc7832"&gt;true&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Copy the Actual meta data to the newly created file.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;foreach&lt;/span&gt; (SPField field &lt;span style="color: #cc7832"&gt;in&lt;/span&gt; sourceFile.Item.Fields)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;if&lt;/span&gt; (field.ReadOnlyField == &lt;span style="color: #cc7832"&gt;false &lt;font color="#ffffff"&gt;&amp;amp;&amp;amp;&lt;/font&gt; &lt;br&gt;&lt;/span&gt;            spDestinationFile.Item.Fields.ContainsField(field.InternalName) == true)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; spDestinationFile.Item[field.InternalName] = sourceFile.Item[field.InternalName];&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Update the meta data&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; spDestinationFile.Item.Update();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Actively strip all meta data&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Hashtable metadata = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; Hashtable(sourceFile.Item.Properties.Count);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;foreach&lt;/span&gt; (&lt;span style="color: #ffc66d"&gt;Object&lt;/span&gt; key &lt;span style="color: #cc7832"&gt;in&lt;/span&gt; sourceFile.Item.Properties.Keys)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; metadata.Add(key, &lt;span style="color: #cc7832"&gt;string&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.Empty);&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Add the file to the site with all meta data stripped&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; spDestinationFile = destinationWeb.Files.Add(destinationFilePath, convertedFile, &lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; metadata, &lt;span style="color: #cc7832"&gt;true&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Check the file back in if this script was responsible for checking it out.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;if&lt;/span&gt; (spDestinationFile.Item.ParentList.ForceCheckout == &lt;span style="color: #cc7832"&gt;true&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; spDestinationFile.CheckIn(&lt;span style="color: #a5c25c"&gt;"Auto check-in after PDF Conversion"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;/div&gt;&amp;nbsp; &lt;li&gt;Click the &lt;i&gt;Actions&lt;/i&gt; button, select &lt;i&gt;Log to History List&lt;/i&gt;, click &lt;i&gt;&lt;u&gt;this message&lt;/u&gt;&lt;/i&gt; and enter &lt;em&gt;File converted to PDF&lt;/em&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;Close the Workflow Designer and update or add an item to your library to trigger the workflow. &lt;br&gt;&amp;nbsp;&lt;/li&gt;&lt;/ol&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="SetPDFSecurity" border="0" alt="SetPDFSecurity" src="http://lh6.ggpht.com/_IgJp5HQ80aU/S1CZTkLXheI/AAAAAAAAALI/MXxu2mYHr8o/SetPDFSecurity%5B7%5D.jpg?imgmax=800" width="575" height="304"&gt; 
&lt;p&gt;&amp;nbsp;&lt;br&gt;Naturally this is just a simple example. Feel free to play around with the code, change which parameters are passed into the workflow or modify where converted PDF files are written to.&lt;/p&gt;
&lt;p&gt;&lt;font color="white"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-7056480293120352225?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/7056480293120352225/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2010/01/configure-pdf-security-from-sharepoint.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/7056480293120352225'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/7056480293120352225'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2010/01/configure-pdf-security-from-sharepoint.html' title='Configure PDF Security from a SharePoint Workflow'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-343498347336637129</id><published>2010-01-11T10:34:00.001Z</published><updated>2010-01-11T10:53:55.050Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='News'/><category scheme='http://www.blogger.com/atom/ns#' term='Products'/><category scheme='http://www.blogger.com/atom/ns#' term='PDF Converter'/><title type='text'>PDF Converter for SharePoint – The first award is in!</title><content type='html'>&lt;p&gt;&lt;img style="border-right-width: 0px; margin: 0px 0px 0px 20px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="party_hat" border="0" alt="party_hat" align="right" src="http://lh6.ggpht.com/_IgJp5HQ80aU/S0r-rrgZMTI/AAAAAAAAAKs/K5RMpq5Fpkk/party_hat%5B9%5D.jpg?imgmax=800" width="94" height="140"&gt; Wow, this is a nice Monday morning surprise. When I checked my mailbox this morning there was an email from SharePointReview’s Inna Gordin announcing that the &lt;a href="http://www.muhimbi.com/Products/PDF-Converter-for-SharePoint/Summary.aspx"&gt;Muhimbi PDF Converter for SharePoint&lt;/a&gt; has won the &lt;a href="http://www.sharepointreviews.com/component/content/article/45-sharepoint-tools/488-PDF-Converter-by-Muhimbi.html#jr_reviewUserSummaryMainTitle"&gt;December 2009 Top User Rated Product Award&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;So, we are now officially Award Winning, which is great. We’ll aim to keep our products’ quality and degree of innovation at a high level to make sure this is not the last award we’ll win.&lt;/p&gt; &lt;p&gt;Please check out our other products on SharePointReviews.com and leave a rating if you like what you see. We are a small company and it really means a lot to our team.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://www.sharepointreviews.com/component/content/article/45-sharepoint-tools/488-PDF-Converter-by-Muhimbi.html#jr_reviewUserSummaryMainTitle"&gt;PDF Converter for SharePoint&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.sharepointreviews.com/component/content/article/57-navigation/558-SharePoint-URL-Shortener-MuSH-by-Muhimbi-.html"&gt;SharePoint URL Shortener&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.sharepointreviews.com/component/content/article/52-design-elements/618-SharePoint-Infuser-by-Muhimbi.html"&gt;SharePoint Infuser&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.sharepointreviews.com/component/content/article/110-sharepoint-development/796-Muhimbi-Workflow-Power-Pack-Embed-C-VB-code-into-SharePoint-Designer.html"&gt;Workflow Power Pack for SharePoint&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.sharepointreviews.com/component/content/article/69-sharepoint-auditing/527-Muhimbi-SharePoint-Audit-Suite.html"&gt;SharePoint Audit Suite&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a href="http://www.sharepointreviews.com/component/content/article/45-sharepoint-tools/488-PDF-Converter-by-Muhimbi.html#jr_reviewUserSummaryMainTitle"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="SPRawards-user-Dec09" border="0" alt="SPRawards-user-Dec09" src="http://lh5.ggpht.com/_IgJp5HQ80aU/S0sDQhFDlFI/AAAAAAAAAK8/F9wpZYBIIVQ/SPRawards-user-Dec09%5B5%5D.png?imgmax=800" width="175" height="157"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt; For the latest news please subscribe to our &lt;a href="http://www.muhimbi.com/blog/feed.xml"&gt;RSS feed&lt;/a&gt; or follow us on &lt;a href="http://twitter.com/Muhimbi"&gt;Twitter&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&lt;font color="white"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-343498347336637129?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/343498347336637129/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2010/01/pdf-converter-for-sharepoint-first.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/343498347336637129'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/343498347336637129'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2010/01/pdf-converter-for-sharepoint-first.html' title='PDF Converter for SharePoint – The first award is in!'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-7636250063434725323</id><published>2010-01-07T15:02:00.001Z</published><updated>2010-01-07T15:05:09.029Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Infuser'/><category scheme='http://www.blogger.com/atom/ns#' term='Articles'/><title type='text'>Using SharePoint Infuser on a Publishing Site</title><content type='html'>&lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; float: right; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="Syringe" border="0" alt="Syringe" align="right" src="http://lh6.ggpht.com/_IgJp5HQ80aU/S0X4JFosEoI/AAAAAAAAAKo/sNHTjGQzJc4/Syringe%5B9%5D.jpg?imgmax=800" width="100" height="123"&gt; We are getting some fantastic feedback from users who are using our &lt;a href="http://www.muhimbi.com/Products/SharePoint-Infuser-(Free).aspx"&gt;free SharePoint Infuser&lt;/a&gt; tool to inject &lt;a href="http://www.muhimbi.com/blog/labels/Infuser.html"&gt;all kinds of Magic&lt;/a&gt; into their SharePoint pages. &lt;/p&gt; &lt;p&gt;However, some users who are using Publishing Sites have reported that the tool is not working for them. This is because the ‘AdditionalPageHead’ delegate control is usually not present in the Master Page of a publishing site.&lt;/p&gt; &lt;p&gt;If you are keen to use Infuser in your Publishing Site then add the following line to your Publishing Site’s master page.&lt;/p&gt; &lt;p&gt;&lt;font size="1" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;SharePoint:DelegateControl runat="server" ControlId="AdditionalPageHead" AllowMultipleControls="true"/&amp;gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;That’s all. Have fun.&lt;/p&gt; &lt;p&gt;&lt;font color="white"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-7636250063434725323?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/7636250063434725323/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2010/01/using-sharepoint-infuser-on-publishing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/7636250063434725323'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/7636250063434725323'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2010/01/using-sharepoint-infuser-on-publishing.html' title='Using SharePoint Infuser on a Publishing Site'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-7425771818686960393</id><published>2009-12-29T13:49:00.001Z</published><updated>2009-12-29T13:57:31.853Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='News'/><category scheme='http://www.blogger.com/atom/ns#' term='WPP'/><category scheme='http://www.blogger.com/atom/ns#' term='Products'/><category scheme='http://www.blogger.com/atom/ns#' term='PDF Converter'/><category scheme='http://www.blogger.com/atom/ns#' term='Workflow'/><category scheme='http://www.blogger.com/atom/ns#' term='Articles'/><title type='text'>Send rich emails with attachments from a SharePoint Designer Workflow</title><content type='html'>&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="email" border="0" alt="email" align="right" src="http://lh3.ggpht.com/_IgJp5HQ80aU/SzoJBHZEitI/AAAAAAAAAKU/JCZ1vc5TvHk/email%5B5%5D.jpg?imgmax=800" width="150" height="148"&gt;One of the most common (sub) tasks executed from a SharePoint workflow is the submission of an email. SharePoint 2007 ships with an Email Workflow Action out of the box, which is unfortunately very limited in its abilities. For example, it is not possible to include attachments, specify the &lt;em&gt;From Address&lt;/em&gt;, set the &lt;em&gt;Priority&lt;/em&gt; or specify the &lt;em&gt;SMTP server&lt;/em&gt; to use.&lt;/p&gt; &lt;p&gt;In this blog post I’ll describe how to send an email from a workflow that automatically includes all files / attachments for the current item from a SharePoint Designer workflow using the &lt;a href="http://www.muhimbi.com/Products/Workflow-Power-Pack-for-SharePoint.aspx"&gt;Workflow Power Pack&lt;/a&gt;. &lt;/p&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2009/12/send-rich-emails-with-attachments-from.html';&lt;/script&gt;&lt;span style="margin-top: 3px; float: left; margin-right: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;A quick introduction for those not familiar with the product: &lt;em&gt;The Muhimbi Workflow Power Pack for SharePoint allows custom C# or VB.NET code to be embedded in SharePoint Designer Workflows without the need to resort to complex Visual Studio based workflows, the development of bespoke Workflow Activities or long development cycles.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;The solution presented below uses the standard &lt;em&gt;Build Dynamic String&lt;/em&gt; Action to create the body of the email. This body is then passed as Parameter 1 to the &lt;em&gt;Execute Custom Code&lt;/em&gt; Action. Parameter 2 is used to specify the &lt;em&gt;To Address&lt;/em&gt;. This code is a great starting point for further customisation. For more details see the standard .net &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.aspx"&gt;MailMessage&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx"&gt;SmtpClient&lt;/a&gt; classes.&lt;/p&gt; &lt;p&gt;Create the workflow as follows:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;&lt;a href="http://www.muhimbi.com/Products/Workflow-Power-Pack-for-SharePoint.aspx"&gt;Download and install the Muhimbi Workflow Power Pack for SharePoint&lt;/a&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;Make sure you have the appropriate privileges to create workflows on a site collection.&lt;br&gt;&amp;nbsp; &lt;li&gt;Create a new workflow using SharePoint Designer.&lt;br&gt;&amp;nbsp; &lt;li&gt;On the &lt;em&gt;Workflow definition screen&lt;/em&gt; associate the workflow with the list or library of your choice, tick the boxes next to both ‘&lt;em&gt;Automatically start… &lt;/em&gt;’ items and proceed to the next screen.&lt;br&gt;&amp;nbsp; &lt;li&gt;Click the &lt;i&gt;Actions&lt;/i&gt; button and insert the &lt;em&gt;Build Dynamic String &lt;/em&gt;action&lt;em&gt;.&lt;br&gt;&amp;nbsp;&lt;/em&gt;  &lt;li&gt;Click &lt;u&gt;dynamic string&lt;/u&gt;&lt;em&gt; &lt;/em&gt;and enter an HTML based email. &lt;br&gt;&amp;nbsp; &lt;li&gt;Click &lt;u&gt;variable1&lt;/u&gt; and create a new string based variable named &lt;em&gt;mailMessage&lt;/em&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;Click the &lt;i&gt;Actions&lt;/i&gt; button and insert the &lt;em&gt;Execute Custom Code &lt;/em&gt;action&lt;em&gt;.&lt;/em&gt;&lt;br&gt;&lt;em&gt;&amp;nbsp;&lt;/em&gt;  &lt;li&gt;Click &lt;u&gt;parameter 1&lt;/u&gt;, open the &lt;em&gt;Workflow Lookup&lt;/em&gt; dialog and select Source: &lt;em&gt;Workflow Data&lt;/em&gt;, Field: &lt;em&gt;mailMessage&lt;/em&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;Click &lt;u&gt;parameter 2 &lt;/u&gt;end enter the address to send the email to. Naturally this could be a lookup value as well.&lt;br&gt;&amp;nbsp; &lt;li&gt;Insert the following C# based code by clicking &lt;u&gt;this code&lt;/u&gt;.&lt;br&gt;&amp;nbsp; &lt;div style="padding-bottom: 8px; padding-left: 8px; padding-right: 8px; font-family: consolas; background: black; color: white; font-size: 8pt; font-weight: bold; padding-top: 8px"&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; System.Net.Mail;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; System.IO;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; smtpServer = MyWorkflow.Site.WebApplication.OutboundMailServiceInstance.Server.Address;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SPListItem item = MyWorkflow.Item;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Get the standard sender address for the Web App. &lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Feel free to replace with an address of your choice.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; from = MyWorkflow.Site.WebApplication.OutboundMailSenderAddress;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; to = (&lt;span style="color: #cc7832"&gt;string&lt;/span&gt;) MyWorkflow.Parameter2;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; subject = &lt;span style="color: #a5c25c"&gt;"New SharePoint Files"&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; body = (&lt;span style="color: #cc7832"&gt;string&lt;/span&gt;) MyWorkflow.Parameter1;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Process any 'workflow variables' that may exist in the body.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;body =&amp;nbsp; Helper.ProcessStringField(body, MyWorkflow.ActivityExecutionContext.Activity, &lt;span style="color: #cc7832"&gt;null&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;MailMessage message = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; MailMessage(from, to, subject, body);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;message.IsBodyHtml = &lt;span style="color: #cc7832"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;message.Priority = MailPriority.Normal;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Add optional CCs and BCCs&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;//message.Bcc.Add("someone@somewhere.com");&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;//message.CC.Add("someone@somewhere.com");&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Do we need to attach a single file or a list of files attached to a list item?&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;if&lt;/span&gt; (item.File != &lt;span style="color: #cc7832"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Attach the file itself&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Stream attachmentStream = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; MemoryStream(item.File.OpenBinary());&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Attachment attachment = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; Attachment(attachmentStream, item.File.Name);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; message.Attachments.Add(attachment);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Attach all files that are part of the list item&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;foreach&lt;/span&gt; (&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; fileName &lt;span style="color: #cc7832"&gt;in&lt;/span&gt; item.Attachments)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SPFile file = item.ParentList.ParentWeb.GetFile(item.Attachments.UrlPrefix + fileName);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Stream attachmentStream = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; MemoryStream(file.OpenBinary());&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Attachment attachment = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; Attachment(attachmentStream, file.Name);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; message.Attachments.Add(attachment);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Send the email&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SmtpClient client = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; SmtpClient(smtpServer);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;client.Send(message);&lt;/pre&gt;&lt;/div&gt;&amp;nbsp; &lt;li&gt;Close the Workflow Designer and add an item to your list or library to trigger the workflow.&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="emailAttachments" border="0" alt="emailAttachments" src="http://lh6.ggpht.com/_IgJp5HQ80aU/SzoJBYna4ZI/AAAAAAAAAKY/OHvCje0Xo0o/emailAttachments%5B5%5D.jpg?imgmax=800" width="575" height="304"&gt; &lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&amp;nbsp;&lt;br&gt;The code in this example is a great starting point for making further customisations. You may want to change which parameters are passed in or load the attachments from a different item or even using an HTTP Request. The solution presented in this post also works very well when combined with one of our other postings: &lt;a href="http://www.muhimbi.com/blog/2009/11/automatically-convert-files-to-pdf.html"&gt;Automatically convert files to PDF using an e-mail enabled SharePoint Document Library&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="white"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-7425771818686960393?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/7425771818686960393/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2009/12/send-rich-emails-with-attachments-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/7425771818686960393'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/7425771818686960393'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2009/12/send-rich-emails-with-attachments-from.html' title='Send rich emails with attachments from a SharePoint Designer Workflow'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-4782548137302281039</id><published>2009-12-28T17:24:00.001Z</published><updated>2009-12-28T17:30:58.174Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='MuSH'/><category scheme='http://www.blogger.com/atom/ns#' term='News'/><category scheme='http://www.blogger.com/atom/ns#' term='WPP'/><category scheme='http://www.blogger.com/atom/ns#' term='Products'/><category scheme='http://www.blogger.com/atom/ns#' term='PDF Converter'/><category scheme='http://www.blogger.com/atom/ns#' term='Workflow'/><category scheme='http://www.blogger.com/atom/ns#' term='Articles'/><title type='text'>Create Shortened (‘TinyURL’) links from your SharePoint Workflow</title><content type='html'>&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="MushBox" border="0" alt="MushBox" align="right" src="http://lh6.ggpht.com/_IgJp5HQ80aU/SzjpwsWbW2I/AAAAAAAAAKM/sSIb6VcYhbc/MushBox%5B5%5D.jpg?imgmax=800" width="200" height="183"&gt;When we released the &lt;a href="http://www.muhimbi.com/Products/SharePoint-URL-Shortener/Summary.aspx"&gt;Muhimbi URL Shortener for SharePoint&lt;/a&gt;, we knew that even though it was a great product, we couldn’t please everyone. For example, all generated Short URLs point to list items’ &lt;em&gt;Form View&lt;/em&gt;, from where the item can be edited, deleted or opened in an external application. This behaviour is by design, but some customers prefer to have the short URL point directly to the file, e.g. a &lt;a href="http://muhimbi.com/blog/2009/04/using-pdf-converter-from-sharepoint.html"&gt;Generated PDF&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;In this article we describe how to generate a short URL from a SharePoint Designer workflow with full control over which view the URL points to using both MuSH and the &lt;a href="http://www.muhimbi.com/Products/Workflow-Power-Pack-for-SharePoint.aspx"&gt;Workflow Power Pack&lt;/a&gt;. &lt;/p&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2009/12/create-shortened-tinyurl-links-from.html';&lt;/script&gt;&lt;span style="margin-top: 3px; float: left; margin-right: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;A quick introduction for those not familiar with the product: &lt;em&gt;The Muhimbi Workflow Power Pack for SharePoint allows custom C# or VB.NET code to be embedded in SharePoint Designer Workflows without the need to resort to complex Visual Studio based workflows, the development of bespoke Workflow Activities or long development cycles.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;The solution presented below creates a short URL for the current item the workflow is acting on. An optional value can be specified in Parameter 1 to control if the generated URL points to the file or &lt;em&gt;display form&lt;/em&gt; using the ‘displayform’ and&amp;nbsp; ‘file’ values.&lt;/p&gt; &lt;p&gt;Create the workflow as follows:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;&lt;a href="http://www.muhimbi.com/Products/Workflow-Power-Pack-for-SharePoint.aspx"&gt;Download and install the Muhimbi Workflow Power Pack for SharePoint&lt;/a&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;a href="http://www.muhimbi.com/Products/SharePoint-URL-Shortener/Summary.aspx"&gt;Download and install the Muhimbi URL Shortener for SharePoint&lt;/a&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;We need to be able to access functionality in the &lt;em&gt;Muhimbi.SharePoint.URLShortener&lt;/em&gt; assembly. Add this reference to the relevant Web Application using the &lt;i&gt;Workflow Power Pack Central Administration screens&lt;/i&gt; as described in the &lt;a href="http://www.muhimbi.com/support/documentation/Workflow-Power-Pack/Administration-Guide.aspx"&gt;Administration Guide&lt;/a&gt;.&lt;br&gt;&amp;nbsp;&amp;nbsp; &lt;li&gt;Make sure you have the appropriate privileges to create workflows on a site collection.&lt;br&gt;&amp;nbsp; &lt;li&gt;Create a new workflow using SharePoint Designer.&lt;br&gt;&amp;nbsp; &lt;li&gt;On the Workflow definition screen associate the workflow with the list or library of your choice, tick the box next to ‘&lt;em&gt;Automatically start this workflow when a new item is created&lt;/em&gt;’ and proceed to the next screen.&lt;br&gt;&amp;nbsp; &lt;li&gt;Click the &lt;i&gt;Actions&lt;/i&gt; button and insert the &lt;em&gt;Execute Custom Code &lt;/em&gt;action&lt;em&gt;.&lt;br&gt;&amp;nbsp; &lt;/em&gt; &lt;li&gt;Click &lt;u&gt;this variable&lt;/u&gt; and create a new Workflow Variable named &lt;em&gt;shortURL&lt;/em&gt; using string as the type.&lt;br&gt;&lt;em&gt;&amp;nbsp;&lt;/em&gt;  &lt;li&gt;Click &lt;u&gt;parameter 1&lt;/u&gt; and enter &lt;em&gt;file&lt;/em&gt; or &lt;em&gt;displayform&lt;/em&gt; or leave it empty to default to &lt;em&gt;displayform.&lt;/em&gt;&lt;br&gt;&amp;nbsp; &lt;li&gt;Insert the following C# based code by clicking &lt;u&gt;this code&lt;/u&gt;.&lt;br&gt;&amp;nbsp; &lt;div style="padding-bottom: 8px; padding-left: 8px; padding-right: 8px; font-family: consolas; background: black; color: white; font-size: 8pt; font-weight: bold; padding-top: 8px"&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; Muhimbi.SharePoint.URLShortener;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Where do we want the shortened URL to point to?&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; target = MyWorkflow.Parameter1 == &lt;span style="color: #cc7832"&gt;null&lt;/span&gt; ? &lt;span style="color: #a5c25c"&gt;"displayform"&lt;/span&gt; : (&lt;span style="color: #ffc66d"&gt;String&lt;/span&gt;) MyWorkflow.Parameter1;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; sourceURL = &lt;span style="color: #cc7832"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Point the short URL to the file or the file's info form&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;switch&lt;/span&gt; (target.ToLower())&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;case&lt;/span&gt; &lt;span style="color: #a5c25c"&gt;"file"&lt;/span&gt;:&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sourceURL = &lt;span style="color: #ffc66d"&gt;String&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.Format(&lt;/span&gt;&lt;span style="color: #a5c25c"&gt;"{0}/{1}"&lt;/span&gt;, MyWorkflow.Web.Url, MyWorkflow.Item.Url);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;case&lt;/span&gt; &lt;span style="color: #a5c25c"&gt;"displayform"&lt;/span&gt;:&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sourceURL = &lt;span style="color: #ffc66d"&gt;String&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.Format(&lt;/span&gt;&lt;span style="color: #a5c25c"&gt;"{0}/{1}?ID={2}"&lt;/span&gt;,&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyWorkflow.Web.Url,&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyWorkflow.List.Forms[PAGETYPE.PAGE_DISPLAYFORM].Url,&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyWorkflow.Item.ID);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;default&lt;/span&gt;:&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;throw&lt;/span&gt; &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; &lt;span style="color: #ffc66d"&gt;ArgumentException&lt;/span&gt;(&lt;span style="color: #a5c25c"&gt;"Unknown target specified, use 'file' or 'displayform'."&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Add a description to the short URL, amend if necessary&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; description = &lt;span style="color: #a5c25c"&gt;"Generated from workflow"&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Carry out the shortening process&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;ShortenedURL shortURL = Muhimbi.SharePoint.URLShortener.&lt;span style="color: #ffc66d"&gt;URLShortener&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.CreateURLViaWebService(&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyWorkflow.Site.WebApplication.Id, sourceURL, description);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Return the fully qualified URL back to the workflow&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;MyWorkflow.ReturnValue = shortURL.GetFullyQualifiedShortURL();&lt;/pre&gt;&lt;/div&gt;&amp;nbsp; &lt;li&gt;Click the &lt;i&gt;Actions&lt;/i&gt; button, select &lt;i&gt;Log to History List&lt;/i&gt;, click &lt;i&gt;&lt;u&gt;this message&lt;/u&gt;&lt;/i&gt;, set the &lt;i&gt;Source &lt;/i&gt;to &lt;i&gt;Workflow Data &lt;/i&gt;and the &lt;i&gt;Field&lt;/i&gt; to &lt;i&gt;shortURL&lt;/i&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;Close the Workflow Designer and add an item to your list or library to trigger the workflow.&lt;br&gt;&amp;nbsp; &lt;li&gt;Once the workflow has finished, click the &lt;em&gt;Completed&lt;/em&gt; link to see the generated short URL. &lt;br&gt;&amp;nbsp; &lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="generateShortURL" border="0" alt="generateShortURL" src="http://lh3.ggpht.com/_IgJp5HQ80aU/SzjpxCkWfdI/AAAAAAAAAKQ/qCVyrgKfA5k/generateShortURL%5B7%5D.jpg?imgmax=800" width="575" height="304"&gt;&amp;nbsp; &lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Naturally this is just a simple example. Under normal circumstances you would do something more useful with the &lt;em&gt;shortURL&lt;/em&gt; workflow variable, for example embed it in an email. &lt;/p&gt;
&lt;p&gt;&lt;font color="white"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-4782548137302281039?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/4782548137302281039/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2009/12/create-shortened-tinyurl-links-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/4782548137302281039'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/4782548137302281039'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2009/12/create-shortened-tinyurl-links-from.html' title='Create Shortened (‘TinyURL’) links from your SharePoint Workflow'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-5150472215606518965</id><published>2009-12-28T11:10:00.001Z</published><updated>2010-01-28T16:44:20.520Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='News'/><category scheme='http://www.blogger.com/atom/ns#' term='WPP'/><category scheme='http://www.blogger.com/atom/ns#' term='Products'/><category scheme='http://www.blogger.com/atom/ns#' term='Workflow'/><category scheme='http://www.blogger.com/atom/ns#' term='Articles'/><title type='text'>Synchronise SharePoint Lists (Calendar/Tasks) using the Workflow Power Pack</title><content type='html'>&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="mirrorCalendars" border="0" alt="mirrorCalendars" align="right" src="http://lh6.ggpht.com/_IgJp5HQ80aU/SziSLLztuSI/AAAAAAAAAKA/vg6DFSnQecw/mirrorCalendars%5B5%5D.jpg?imgmax=800" width="130" height="157"&gt;When I worked in the SharePoint team for a London based financial firm, one of the first user requests that came up was to find an easy way to synchronise team calendar entries with a department level calendar. &lt;/p&gt; &lt;p&gt;There are a number of ways to approach the automatic synchronisation of lists (a Calendar is just a SharePoint list). In this posting I will discuss how to synchronise any source list with a destination list, with the Exception of Document Libraries, using the &lt;a href="http://www.muhimbi.com/blog/2009/12/embed-c-or-vb-code-directly-in.html"&gt;Muhimbi Workflow Power Pack&lt;/a&gt; and a small script.&lt;/p&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2009/12/automatically-synchronise-sharepoint.html';&lt;/script&gt;&lt;span style="margin-top: 3px; float: left; margin-right: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;A quick introduction for those not familiar with the product: &lt;em&gt;The Muhimbi Workflow Power Pack for SharePoint allows custom C# or VB.NET code to be embedded in SharePoint Designer Workflows without the need to resort to complex Visual Studio based workflows, the development of bespoke Workflow Activities or long development cycles.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;Before developing the script we have to think about our approach as the synchronisation of list items involves both adding new items as well as updating existing ones. In order to be able to update an item we need to somehow track which item in the destination list is a copy of an item in the source list. As SharePoint does not provide an easy way to track this kind of information (The &lt;em&gt;CopySource&lt;/em&gt; field is read only, sigh) the script will need to create a new and hidden field on the destination list to track an item’s origin.&lt;/p&gt; &lt;p&gt;The solution presented below allows any two lists to be synchronised in one direction (Source List to Destination List). The name of the Destination List is passed using &lt;em&gt;Parameter 1&lt;/em&gt;. Only those fields available in both the source and destination lists will be copied over so there is no need for the two lists to have exactly the same content type. The very first time the script is executed, a new hidden field will be created on the Destination List, so make sure you execute the first run using an account that has the appropriate privileges to add columns to the list.&lt;/p&gt; &lt;p&gt;Create the workflow as follows:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;&lt;a href="http://www.muhimbi.com/Products/Workflow-Power-Pack-for-SharePoint.aspx"&gt;Download and install the Muhimbi Workflow Power Pack for SharePoint&lt;/a&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;Make sure you have the appropriate privileges to create workflows on a site collection.&lt;br&gt;&amp;nbsp; &lt;li&gt;Create a source and destination list, e.g. &lt;em&gt;Calendar&lt;/em&gt; and &lt;em&gt;Destination Calendar&lt;/em&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;Create a new workflow using SharePoint Designer.&lt;br&gt;&amp;nbsp; &lt;li&gt;On the Workflow definition screen associate the workflow with the source list and tick the two &lt;em&gt;automatic&lt;/em&gt; boxes and proceed to the next screen.&lt;br&gt;&amp;nbsp; &lt;li&gt;Click the &lt;i&gt;Actions&lt;/i&gt; button and insert the &lt;em&gt;Execute Custom Code &lt;/em&gt;action&lt;em&gt;.&lt;br&gt;&amp;nbsp;&lt;/em&gt;  &lt;li&gt;Click &lt;u&gt;parameter 1&lt;/u&gt; and enter the name of the Destination List. &lt;br&gt;&amp;nbsp; &lt;li&gt;Insert the following C# based code by clicking &lt;u&gt;this code&lt;/u&gt;.&lt;br&gt;&amp;nbsp; &lt;div style="padding-bottom: 8px; padding-left: 8px; padding-right: 8px; font-family: consolas; background: black; color: white; font-size: 8pt; font-weight: bold; padding-top: 8px"&gt;&lt;pre style="margin: 0px"&gt;SPList sourceList = MyWorkflow.List;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SPList destinationList = MyWorkflow.Web.Lists[MyWorkflow.Parameter1 &lt;span style="color: #cc7832"&gt;as&lt;/span&gt; &lt;span style="color: #ffc66d"&gt;String&lt;/span&gt;];&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SPListItem sourceItem = MyWorkflow.Item;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Check if our custom Source field already exists on the destination list&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;if&lt;/span&gt; (destinationList.Fields.ContainsField(&lt;span style="color: #a5c25c"&gt;"_M_CopySource"&lt;/span&gt;) == &lt;span style="color: #cc7832"&gt;false&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SPField newField = destinationList.Fields.CreateNewField(&lt;span style="color: #a5c25c"&gt;"Text"&lt;/span&gt;, &lt;span style="color: #a5c25c"&gt;"_M_CopySource"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newField.Hidden = &lt;span style="color: #cc7832"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; destinationList.Fields.Add(newField);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Check if the item needs to be copied or updated.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; camlQuery = &lt;span style="color: #a5c25c"&gt;"&amp;lt;Where&amp;gt;"&lt;/span&gt; +&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #a5c25c"&gt;"&amp;lt;Eq&amp;gt;&amp;lt;FieldRef Name='_M_CopySource'/&amp;gt;&amp;lt;Value Type='Text'&amp;gt;{0}&amp;lt;/Value&amp;gt;&amp;lt;/Eq&amp;gt;"&lt;/span&gt; +&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #a5c25c"&gt;"&amp;lt;/Where&amp;gt;"&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;camlQuery = &lt;span style="color: #cc7832"&gt;string&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.Format(camlQuery, sourceItem[&lt;/span&gt;&lt;span style="color: #a5c25c"&gt;"FileRef"&lt;/span&gt;]);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SPQuery query = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; SPQuery();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;query.Query = camlQuery;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;query.RowLimit = &lt;span style="color: #6897bb"&gt;1&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Query the list&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SPListItemCollection items = destinationList.GetItems(query);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SPListItem newItem = &lt;span style="color: #cc7832"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;if&lt;/span&gt; (items.Count == &lt;span style="color: #6897bb"&gt;0&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newItem = destinationList.Items.Add();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newItem = items[&lt;span style="color: #6897bb"&gt;0&lt;/span&gt;];&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Copy the fields&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;foreach&lt;/span&gt;(SPField field &lt;span style="color: #cc7832"&gt;in&lt;/span&gt; sourceItem.Fields)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;if&lt;/span&gt; (newItem.Fields.ContainsField(field.InternalName) == &lt;span style="color: #cc7832"&gt;true&lt;/span&gt; &amp;amp;&amp;amp; &lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; field.ReadOnlyField == &lt;span style="color: #cc7832"&gt;false&lt;/span&gt; &amp;amp;&amp;amp; field.InternalName != &lt;span style="color: #a5c25c"&gt;"Attachments"&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newItem[field.InternalName] = sourceItem[field.InternalName];&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Delete any existing attachments in the target item&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;for&lt;/span&gt; (&lt;span style="color: #cc7832"&gt;int&lt;/span&gt; i = newItem.Attachments.Count; i &amp;gt; &lt;span style="color: #6897bb"&gt;0&lt;/span&gt;; i-- )&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newItem.Attachments.Delete(newItem.Attachments[i-&lt;span style="color: #6897bb"&gt;1&lt;/span&gt;]);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Copy any attachments&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;foreach&lt;/span&gt; (&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; fileName &lt;span style="color: #cc7832"&gt;in&lt;/span&gt; sourceItem.Attachments)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SPFile file = sourceItem.ParentList.ParentWeb.GetFile(sourceItem.Attachments.UrlPrefix + &lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fileName);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;byte&lt;/span&gt;[] imageData = file.OpenBinary();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newItem.Attachments.Add(fileName, imageData);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Remember where the original was copied from so we can update it in the future&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;newItem[&lt;span style="color: #a5c25c"&gt;"_M_CopySource"&lt;/span&gt;] = sourceItem[&lt;span style="color: #a5c25c"&gt;"FileRef"&lt;/span&gt;];&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;newItem.Update();&lt;/pre&gt;&lt;/div&gt;&amp;nbsp; &lt;li&gt;Close the Workflow Designer and add an item to the source list to trigger the workflow.&lt;br&gt;&amp;nbsp; &lt;li&gt;Once the workflow has finished, open the destination list and verify the source item has been copied over. &lt;br&gt;&amp;nbsp;&lt;br&gt;&amp;nbsp; &lt;a href="http://lh3.ggpht.com/_IgJp5HQ80aU/SziSLiq4vmI/AAAAAAAAAKE/zR30u5z5G74/s1600-h/mirrorCalendarEntries%5B4%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="mirrorCalendarEntries" border="0" alt="mirrorCalendarEntries" src="http://lh4.ggpht.com/_IgJp5HQ80aU/SziSMBzX4cI/AAAAAAAAAKI/EPaOOCSMYNI/mirrorCalendarEntries_thumb%5B2%5D.jpg?imgmax=800" width="575" height="304"&gt;&lt;/a&gt;&amp;nbsp;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;As mentioned previously, it should be possible to use this script on any list with the exception of Document Libraries. Synchronising Document Libraries can be done using a similar approach, but copying an item works slightly different. &lt;/p&gt;
&lt;p&gt;The script in this post assumes the destination list lives in the same site as the source list. This, however, can be easily changed by referencing the desired list in line 2 of the code.&lt;/p&gt;
&lt;p&gt;You may want to add a condition to only synchronise list items that match certain criteria (e.g. status = completed). &lt;/p&gt;
&lt;p&gt;&lt;font color="white"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-5150472215606518965?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/5150472215606518965/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2009/12/automatically-synchronise-sharepoint.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/5150472215606518965'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/5150472215606518965'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2009/12/automatically-synchronise-sharepoint.html' title='Synchronise SharePoint Lists (Calendar/Tasks) using the Workflow Power Pack'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-5962750662971144168</id><published>2009-12-23T09:05:00.001Z</published><updated>2009-12-28T11:13:17.633Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='News'/><category scheme='http://www.blogger.com/atom/ns#' term='WPP'/><category scheme='http://www.blogger.com/atom/ns#' term='Products'/><category scheme='http://www.blogger.com/atom/ns#' term='PDF Converter'/><category scheme='http://www.blogger.com/atom/ns#' term='Workflow'/><category scheme='http://www.blogger.com/atom/ns#' term='Articles'/><title type='text'>Automatically mirror / sync a SharePoint folder structure using the Workflow Power Pack</title><content type='html'>&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Mirror" border="0" alt="Mirror" align="right" src="http://lh4.ggpht.com/_IgJp5HQ80aU/SzHdSwALNGI/AAAAAAAAAJw/R-jS7zKOr4A/Mirror%5B5%5D.jpg?imgmax=800" width="130" height="155"&gt; Quite a few of our customers use a SharePoint Designer workflow to &lt;a href="http://muhimbi.com/blog/2009/04/using-pdf-converter-from-sharepoint.html"&gt;automatically create PDF files&lt;/a&gt; whenever a document is created or modified in a SharePoint Document Library. Some of these customers want to use the same directory structure for the source files as well as the converted files. &lt;/p&gt; &lt;p&gt;The problem that we’ll address in this posting is how to automatically synchronise the two directory structures using the &lt;a href="http://www.muhimbi.com/blog/2009/12/embed-c-or-vb-code-directly-in.html"&gt;Muhimbi Workflow Power Pack&lt;/a&gt; and a small script.&lt;/p&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2009/12/automatically-create-mirrored.html';&lt;/script&gt;&lt;span style="margin-top: 3px; float: left; margin-right: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;A quick introduction for those not familiar with the product: &lt;em&gt;The Muhimbi Workflow Power Pack for SharePoint allows custom C# or VB.NET code to be embedded in SharePoint Designer Workflows without the need to resort to complex Visual Studio based workflows, the development of bespoke Workflow Activities or long development cycles.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;The script we’ll develop is executed every time a file is created anywhere in a document library. The file’s path will be extracted and replicated in the destination Document Library. Ideally we would only like to trigger this workflow whenever a new folder is created, but using SharePoint designer it is not possible to trigger workflows for folders.&lt;/p&gt; &lt;p&gt;At the end of the custom activity the destination path is returned to the workflow, from where it can be used for further processing.&lt;/p&gt; &lt;p&gt;Create the workflow as follows:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;&lt;a href="http://www.muhimbi.com/Products/Workflow-Power-Pack-for-SharePoint.aspx"&gt;Download and install the Muhimbi Workflow Power Pack for SharePoint&lt;/a&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;Make sure you have the appropriate privileges to create workflows on a site collection.&lt;br&gt;&amp;nbsp; &lt;li&gt;Create a source and destination Document Library. Alternatively use the same Document Library for the source and the destination, just create a new folder in the root to mirror the folder structure to. &lt;br&gt;&amp;nbsp; &lt;li&gt;Create a new workflow using SharePoint Designer.&lt;br&gt;&amp;nbsp; &lt;li&gt;On the Workflow definition screen associate the workflow with the Source Document Library&amp;nbsp; and tick the box next to “Automatically start this workflow when a new item is created” and proceed to the next screen.&lt;br&gt;&amp;nbsp; &lt;li&gt;Click the &lt;i&gt;Actions&lt;/i&gt; button and insert the &lt;em&gt;Execute Custom Code &lt;/em&gt;action&lt;em&gt;.&lt;br&gt;&amp;nbsp;&lt;/em&gt;  &lt;li&gt;Click &lt;u&gt;this variable&lt;/u&gt; and create a new Workflow Variable named &lt;i&gt;destinationPath&lt;/i&gt; using &lt;i&gt;string &lt;/i&gt;as the type.&lt;br&gt;&amp;nbsp; &lt;li&gt;Insert the following C# based code by clicking &lt;u&gt;this code&lt;/u&gt;.&lt;br&gt;&amp;nbsp; &lt;div style="padding-bottom: 8px; padding-left: 8px; padding-right: 8px; font-family: consolas; background: black; color: white; font-size: 8pt; font-weight: bold; padding-top: 8px"&gt;&lt;pre style="margin: 0px"&gt;SPList sourceList = MyWorkflow.List;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** The destination Document Library (optionally point it to a different site collection)&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SPList destinationList = MyWorkflow.Web.Lists[&lt;span style="color: #a5c25c"&gt;"Some Destination DocLib"&lt;/span&gt;];&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** If the destination directory structure should not start in the root directory, enter&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** the folder path to the root destination folder here&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; rootFolderName = &lt;span style="color: #a5c25c"&gt;""&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; destinationListURL = destinationList.RootFolder.ServerRelativeUrl + rootFolderName;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Generate a list of folders for the current item&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SPListItem sourceFile = MyWorkflow.Item;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #ffc66d"&gt;Stack&lt;/span&gt;&lt;span style="font-weight: normal"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt;&lt;span style="font-weight: normal"&gt;&amp;gt; folders = &lt;/span&gt;&lt;span style="color: #cc7832"&gt;new&lt;/span&gt; &lt;span style="color: #ffc66d"&gt;Stack&lt;/span&gt;&lt;span style="font-weight: normal"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt;&lt;span style="font-weight: normal"&gt;&amp;gt;();&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;SPFolder folder = sourceFile.File.ParentFolder;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;while&lt;/span&gt; (folder.Name != &lt;span style="color: #cc7832"&gt;string&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.Empty)&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; folders.Push(folder.Name);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; folder = folder.ParentFolder;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** discard the first as it is the name of the Doc lib itself&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;folders.Pop();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Iterate through the list of folders in reverse&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;while&lt;/span&gt;(folders.Count != &lt;span style="color: #6897bb"&gt;0&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;string&lt;/span&gt; folderToCreate = folders.Pop();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Check if the folder already exists, in which case no action is required&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; folder = destinationList.ParentWeb.GetFolder(destinationListURL + &lt;span style="color: #a5c25c"&gt;"/"&lt;/span&gt; + folderToCreate);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;if&lt;/span&gt; (folder.Exists == &lt;span style="color: #cc7832"&gt;false&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Create the new folder&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SPListItem newFolder = destinationList.Items.Add(destinationListURL, &lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SPFileSystemObjectType.Folder, folderToCreate);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newFolder.Update();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; destinationListURL += &lt;span style="color: #a5c25c"&gt;"/"&lt;/span&gt; + folderToCreate;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;MyWorkflow.ReturnValue = destinationListURL;&lt;/pre&gt;&lt;/div&gt;&amp;nbsp;&amp;nbsp; &lt;li&gt;Update the &lt;em&gt;destinationList&lt;/em&gt; and &lt;em&gt;rootFolderName&lt;/em&gt; variables to match your situation.&lt;br&gt;&amp;nbsp; &lt;li&gt;Click the &lt;i&gt;Actions&lt;/i&gt; button, select &lt;i&gt;Log to History List&lt;/i&gt;, click &lt;i&gt;&lt;u&gt;this message&lt;/u&gt;&lt;/i&gt;, set the &lt;i&gt;Source &lt;/i&gt;to &lt;i&gt;Workflow Data &lt;/i&gt;and the &lt;i&gt;Field&lt;/i&gt; to &lt;i&gt;destinationPath&lt;/i&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;Close the Workflow Designer and add an item somewhere in a nested folder in the source Document Library to trigger the workflow.&lt;br&gt;&amp;nbsp; &lt;li&gt;Once the workflow has finished, click the &lt;i&gt;Completed&lt;/i&gt; link to see which path the new folder has been created in. Check that the destination folder(s) have been created by navigating to the Destination Library.&lt;br&gt;&amp;nbsp;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="mirrorFolders" border="0" alt="mirrorFolders" src="http://lh3.ggpht.com/_IgJp5HQ80aU/SzHdTd-cmKI/AAAAAAAAAJ4/XiZ1XGac4_I/mirrorFolders%5B8%5D.jpg?imgmax=800" width="571" height="300"&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In case you want to use this in combination with &lt;a href="http://www.muhimbi.com/Products/PDF-Converter-for-SharePoint/Summary.aspx"&gt;Muhimbi’s PDF Converter for SharePoint&lt;/a&gt; then you can use the path returned in the &lt;em&gt;destinationPath&lt;/em&gt; variable and use it as the destination URL in the &lt;em&gt;Convert To PDF&lt;/em&gt; workflow activity. If you want to use it in combination with something else, then use it as you see fit.&lt;/p&gt;
&lt;p&gt;Note that a small change may be required to the script, or perhaps as a &lt;em&gt;Custom Code Condition&lt;/em&gt;, if the source and destination Document Libraries are the same and files will be written to the location specified in &lt;em&gt;rootFolderName&lt;/em&gt;. Otherwise the folder structure inside the destination folder will be mirrored in the destination folder, just at a deeper level.&lt;/p&gt;
&lt;p&gt;&lt;font color="white"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-5962750662971144168?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/5962750662971144168/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2009/12/automatically-create-mirrored.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/5962750662971144168'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/5962750662971144168'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2009/12/automatically-create-mirrored.html' title='Automatically mirror / sync a SharePoint folder structure using the Workflow Power Pack'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-8306022946756125934</id><published>2009-12-22T15:27:00.001Z</published><updated>2010-02-09T14:24:33.556Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='News'/><category scheme='http://www.blogger.com/atom/ns#' term='WPP'/><category scheme='http://www.blogger.com/atom/ns#' term='Products'/><category scheme='http://www.blogger.com/atom/ns#' term='Workflow'/><category scheme='http://www.blogger.com/atom/ns#' term='Articles'/><title type='text'>SharePoint Workflow Power Pack User Guide - Embedding .net code in a Workflow Action</title><content type='html'>&lt;p&gt;&lt;img style="position: relative; border-right-width: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; margin-left: 15px; border-left-width: 0px; top: -23px; margin-right: 0px" title="User-Guide" border="0" alt="User-Guide" src="http://lh6.ggpht.com/_IgJp5HQ80aU/SzDlVsZnZ1I/AAAAAAAAAJo/uXfCSkpzAGI/User-Guide%5B4%5D.jpg?imgmax=800" width="130" height="167"&gt;In part 3 of our series of &lt;a href="http://www.muhimbi.com/support/documentation/Workflow-Power-Pack/User-Guide.aspx"&gt;User Guide&lt;/a&gt; related blog postings for the &lt;a href="http://www.muhimbi.com/blog/2009/12/embed-c-or-vb-code-directly-in.html"&gt;Muhimbi Workflow Power Pack for SharePoint&lt;/a&gt; we provide an example of how to embed c# or vb code directly into a SharePoint Designer Workflow Action.&lt;/p&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2009/12/sharepoint-workflow-power-pack-user_22.html';&lt;/script&gt;&lt;span style="margin-top: 3px; float: left; margin-right: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;A quick introduction In case you are not familiar with the product: &lt;em&gt;The Muhimbi Workflow Power Pack for SharePoint allows custom C# or VB.NET code to be embedded in SharePoint Designer Workflows without the need to resort to complex Visual Studio based workflows, the development of bespoke Workflow Activities or long development cycles.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;The following Blog postings are part of this User Guide series:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/2009/12/workflow-power-pack-user-guide-language.html"&gt;Language Features&lt;/a&gt;: Discusses the &lt;em&gt;script like&lt;/em&gt; syntax, the generic workflow action and condition, passing parameters, returning values from a workflow and using the &lt;em&gt;MyWorkflow&lt;/em&gt; property.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/2009/12/sharepoint-workflow-power-pack-user.html"&gt;Embedding .net code in a Workflow Condition&lt;/a&gt;: Provides a number of examples of how to use the &lt;em&gt;Evaluate Custom Code&lt;/em&gt; condition to carry out basic as well as complex conditional tasks.&lt;br&gt;&amp;nbsp; &lt;li&gt;Embedding .net code in a Workflow Action (this article): Contains a number of examples of how to use the &lt;em&gt;Execute Custom Code&lt;/em&gt;&amp;nbsp; to basically carry out any action you can think of in a SharePoint Designer Workflow.&lt;br&gt;&amp;nbsp;&amp;nbsp; &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/2010/02/sharepoint-workflow-power-pack-user.html"&gt;Creating Custom Methods&lt;/a&gt;: Shows how to create your own methods in your scripts in order to keep the code organised and easy to maintain. &lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;br&gt;&amp;nbsp;&lt;br&gt;&lt;/p&gt; &lt;p&gt; &lt;hr align="center" width="250"&gt;  &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;br&gt;SharePoint ships with a number of &lt;em&gt;Workflow Actions&lt;/em&gt; to carry out basic tasks such as setting the value of an item or sending an email. However, if you need to do something slightly different that is not supported by any of the stock actions, you need to resort to expensive third party utilities that may match some of your requirements, but probably not all of them. &lt;/p&gt; &lt;p&gt;This section describes how to use the Muhimbi Workflow Power Pack to implement your exact requirements without any limits or dependencies on third party logic. See &lt;a href="http://www.muhimbi.com/blog/2009/12/sharepoint-workflow-power-pack-user.html"&gt;part 2 of this series&lt;/a&gt; for another example that automatically renames a file based on keywords in its name.  &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Reading a SQL Database using a Workflow Action&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Although SharePoint can be used to store much of your data, in reality a typical enterprise stores data in all kind of formats and data stores.  &lt;p&gt;In this example we’ll discuss how to use the Muhimbi Workflow Power Pack to retrieve data stored in a SQL Server Database. The example is not particularly practical as we just read a group name out of the SharePoint Content Database, however the same principle can be used for any database.  &lt;p&gt;To create this workflow, carry out the following steps:  &lt;ol&gt; &lt;li&gt;We need to be able to access functionality in the &lt;i&gt;System.Data&lt;/i&gt; assembly. Add this reference to the relevant Web Application using the &lt;i&gt;Workflow Power Pack Central Administration screens&lt;/i&gt; as described in the &lt;a href="http://www.muhimbi.com/support/documentation/Workflow-Power-Pack/Administration-Guide.aspx"&gt;Administration Guide&lt;/a&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;Make sure you have the appropriate privileges to create workflows on a site collection.&lt;br&gt;&amp;nbsp; &lt;li&gt;Create a new workflow using SharePoint Designer.&lt;br&gt;&amp;nbsp; &lt;li&gt;On the Workflow definition screen associate the workflow with your list of choice (any list will do), tick the two “automatically start” check boxes and proceed to the next screen.&lt;br&gt;&amp;nbsp; &lt;li&gt;Click the &lt;i&gt;Actions&lt;/i&gt; button and insert the &lt;em&gt;Execute Custom Code &lt;/em&gt;action&lt;em&gt;.&lt;br&gt;&amp;nbsp;&lt;/em&gt;  &lt;li&gt;Click &lt;u&gt;this variable&lt;/u&gt; and create a new Workflow Variable named &lt;i&gt;groupName&lt;/i&gt; using &lt;i&gt;string &lt;/i&gt;as the type.&lt;br&gt;&amp;nbsp; &lt;li&gt;Insert the following C# based code by clicking &lt;u&gt;this code&lt;/u&gt;.&lt;br&gt;&amp;nbsp; &lt;div style="padding-bottom: 8px; padding-left: 8px; padding-right: 8px; font-family: consolas; background: black; color: white; font-size: 8pt; font-weight: bold; padding-top: 8px"&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; System.Data.SqlClient;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Get the connection string for the content DB&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; connString = &lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyWorkflow.Site.WebApplication.ContentDatabases[&lt;span style="color: #6897bb"&gt;0&lt;/span&gt;].DatabaseConnectionString;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt;(SqlConnection connection = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; SqlConnection(connString))&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; connection.Open();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Execute the Query&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;string&lt;/span&gt; sql = &lt;span style="color: #a5c25c"&gt;"SELECT TOP (1) Title FROM Groups"&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SqlCommand cmd = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; SqlCommand(sql, connection);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Store the result in the ReturnValue&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SqlDataReader reader = cmd.ExecuteReader();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;if&lt;/span&gt;(reader.Read() == &lt;span style="color: #cc7832"&gt;true&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyWorkflow.ReturnValue = reader[&lt;span style="color: #a5c25c"&gt;"Title"&lt;/span&gt;].ToString();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;/div&gt;&amp;nbsp; &lt;li&gt;Click the &lt;i&gt;Actions&lt;/i&gt; button, select &lt;i&gt;Log to History List&lt;/i&gt;, click &lt;i&gt;&lt;u&gt;this message&lt;/u&gt;&lt;/i&gt;, set the &lt;i&gt;Source &lt;/i&gt;to &lt;i&gt;Workflow Data &lt;/i&gt;and the &lt;i&gt;Field&lt;/i&gt; to &lt;i&gt;groupName&lt;/i&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;Close the Workflow Designer and add / update an item in the list to trigger the workflow.&lt;br&gt;&amp;nbsp; &lt;li&gt;Once the workflow has finished, click the &lt;i&gt;Completed&lt;/i&gt; link to see the output.&lt;br&gt;&amp;nbsp;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="SQLAccess" border="0" alt="SQLAccess" src="http://lh3.ggpht.com/_IgJp5HQ80aU/SzDlWArez9I/AAAAAAAAAJs/A15vR2kEPuY/SQLAccess%5B7%5D.png?imgmax=800" width="575" height="304"&gt; &lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&lt;br&gt;We are connecting to the content database in this example to make it easier to execute as no new databases or connection strings need to be created. 
&lt;p&gt;&lt;font color="white"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-8306022946756125934?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/8306022946756125934/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2009/12/sharepoint-workflow-power-pack-user_22.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/8306022946756125934'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/8306022946756125934'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2009/12/sharepoint-workflow-power-pack-user_22.html' title='SharePoint Workflow Power Pack User Guide - Embedding .net code in a Workflow Action'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-6825646643810692123</id><published>2009-12-22T14:01:00.001Z</published><updated>2010-02-09T14:25:29.459Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='News'/><category scheme='http://www.blogger.com/atom/ns#' term='WPP'/><category scheme='http://www.blogger.com/atom/ns#' term='Products'/><category scheme='http://www.blogger.com/atom/ns#' term='Workflow'/><category scheme='http://www.blogger.com/atom/ns#' term='Articles'/><title type='text'>SharePoint Workflow Power Pack User Guide - Embedding .net code in a Workflow Condition</title><content type='html'>&lt;p&gt;&lt;img style="position: relative; border-right-width: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; margin-left: 15px; border-left-width: 0px; top: -23px; margin-right: 0px" title="User-Guide" border="0" alt="User-Guide" align="right" src="http://lh4.ggpht.com/_IgJp5HQ80aU/SzDRIQPWODI/AAAAAAAAAJc/1LaqN1CFCXo/User-Guide%5B5%5D.jpg?imgmax=800" width="130" height="167"&gt; In part 2 of our series of &lt;a href="http://www.muhimbi.com/support/documentation/Workflow-Power-Pack/User-Guide.aspx"&gt;User Guide&lt;/a&gt; related blog postings for the &lt;a href="http://www.muhimbi.com/blog/2009/12/embed-c-or-vb-code-directly-in.html"&gt;Muhimbi Workflow Power Pack for SharePoint&lt;/a&gt; we provide a number of examples of how to embed c# or vb code directly into a SharePoint Designer Workflow Condition.&lt;/p&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2009/12/sharepoint-workflow-power-pack-user.html';&lt;/script&gt;&lt;span style="margin-top: 3px; float: left; margin-right: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;A quick introduction In case you are not familiar with the product: &lt;em&gt;The Muhimbi Workflow Power Pack for SharePoint allows custom C# or VB.NET code to be embedded in SharePoint Designer Workflows without the need to resort to complex Visual Studio based workflows, the development of bespoke Workflow Activities or long development cycles.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;The following Blog postings are part of this User Guide series:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/2009/12/workflow-power-pack-user-guide-language.html"&gt;Language Features&lt;/a&gt;: Discusses the &lt;em&gt;script like&lt;/em&gt; syntax, the generic workflow action and condition, passing parameters, returning values from a workflow and using the &lt;em&gt;MyWorkflow&lt;/em&gt; property.&lt;br&gt;&amp;nbsp; &lt;li&gt;Embedding .net code in a Workflow Condition (this article): Provides a number of examples of how to use the &lt;em&gt;Evaluate Custom Code&lt;/em&gt; condition to carry out basic as well as complex conditional tasks.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/2009/12/sharepoint-workflow-power-pack-user_22.html"&gt;Embedding .net code in a Workflow Action&lt;/a&gt;: Contains a number of examples of how to use the &lt;em&gt;Execute Custom Code&lt;/em&gt;&amp;nbsp; to basically carry out any action you can think of in a SharePoint Designer Workflow.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/2010/02/sharepoint-workflow-power-pack-user.html"&gt;Creating Custom Methods&lt;/a&gt;: Shows how to create your own methods in your scripts in order to keep the code organised and easy to maintain. &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;&amp;nbsp;&lt;br&gt; &lt;hr align="center" width="250"&gt; &lt;br&gt;&amp;nbsp;&lt;br&gt; &lt;p&gt;SharePoint ships with a number of &lt;em&gt;Workflow Conditions&lt;/em&gt; to carry out basic comparisons inside your SharePoint Designer workflows. However, these Conditions are limited in scope and mainly facilitate simple comparisons of workflow variables.&amp;nbsp; &lt;p&gt;This post describes how to use the Muhimbi Workflow Power Pack to write your own conditional logic in c# and embed it directly into your SharePoint Designer workflow.  &lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;a name="_Toc248984939"&gt;&lt;/a&gt;&lt;a name="_Ref248916905"&gt;&lt;/a&gt;&lt;a name="_Ref248916900"&gt;&lt;strong&gt;Simple Example - File name validation&lt;/strong&gt;&lt;/a&gt;  &lt;p&gt;The following example shows how to check if a document’s file name contains a reference to a highly confidential project (Project &lt;i&gt;Flames&lt;/i&gt;). If it does then the document will be renamed automatically.  &lt;p&gt;To create this workflow, carry out the following steps:  &lt;ol&gt; &lt;li&gt;Make sure you have access to a Document Library in a site collection and the appropriate privileges to design a workflow on that site collection.&lt;br&gt;&amp;nbsp; &lt;li&gt;Create a new workflow using SharePoint Designer.&lt;br&gt;&amp;nbsp; &lt;li&gt;On the Workflow definition screen associate the workflow with your Document Library, tick the two “automatically start” check boxes and proceed to the next screen.&lt;br&gt;&amp;nbsp; &lt;li&gt;Click the &lt;i&gt;Conditions&lt;/i&gt; button and insert the &lt;i&gt;Evaluate Custom Code &lt;/i&gt;&lt;i&gt;condition.&lt;br&gt;&amp;nbsp;&lt;/i&gt;  &lt;li&gt;Insert the following C# based code by clicking &lt;u&gt;code&lt;/u&gt; and then the ellipsis (…) button.&lt;br&gt;&lt;br&gt; &lt;div style="padding-bottom: 8px; padding-left: 8px; padding-right: 8px; font-family: consolas; background: black; color: white; font-size: 8pt; font-weight: bold; padding-top: 8px"&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;if&lt;/span&gt; (MyWorkflow.Item.Name.IndexOf(&lt;span style="color: #a5c25c"&gt;"Flames"&lt;/span&gt;, &lt;span style="color: #6897bb"&gt;StringComparison&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.CurrentCultureIgnoreCase) &amp;gt;= &lt;/span&gt;&lt;span style="color: #6897bb"&gt;0&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyWorkflow.ReturnValue = &lt;span style="color: #cc7832"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyWorkflow.ReturnValue = &lt;span style="color: #cc7832"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;/div&gt;&amp;nbsp; &lt;li&gt;Add the &lt;i&gt;Execute Custom Code&lt;/i&gt; Action and insert the following code by clicking &lt;u&gt;this code&lt;/u&gt; and pasting the following.&lt;br&gt;&amp;nbsp; &lt;div style="padding-bottom: 8px; padding-left: 8px; padding-right: 8px; font-family: consolas; background: black; color: white; font-size: 8pt; font-weight: bold; padding-top: 8px"&gt;&lt;pre style="margin: 0px"&gt;MyWorkflow.Item[&lt;span style="color: #a5c25c"&gt;"Name"&lt;/span&gt;] = MyWorkflow.Item.Name.Replace(&lt;span style="color: #a5c25c"&gt;"Flames"&lt;/span&gt;, &lt;span style="color: #a5c25c"&gt;"XXXXX"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;MyWorkflow.Item.Update();&lt;/pre&gt;&lt;/div&gt;&amp;nbsp; &lt;li&gt;Close the workflow designer. This will automatically check the syntax of the code embedded in the Custom Action. &lt;br&gt;&amp;nbsp;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="CheckFileName" border="0" alt="CheckFileName" src="http://lh3.ggpht.com/_IgJp5HQ80aU/SzDRIs8M_BI/AAAAAAAAAJg/LC4wqTiRGBs/CheckFileName%5B6%5D.png?imgmax=800" width="571" height="300"&gt; 
&lt;p&gt;&lt;br&gt;The workflow is now ready to be executed. Upload a file named “&lt;i&gt;Project Flames Hostile Takeover.docx&lt;/i&gt;” and watch it being renamed automatically. 
&lt;p&gt;In this simple example we could have merged the conditional code into the Action. However that would not work with more complex workflows where the Action does not necessarily contain our own custom code.&lt;/p&gt;&amp;nbsp;&lt;br&gt;
&lt;hr align="center" width="250"&gt;
&lt;br&gt;&amp;nbsp; &lt;p&gt;&lt;a name="_Toc248984940"&gt;&lt;strong&gt;Complex example - Check field in InfoPath form&lt;/strong&gt;&lt;/a&gt; 
&lt;p&gt;As we have access to the full power of the .net framework, there are very few limitations to how complex the conditional code can be. In the following example we will check the value of a field stored deeply in an XML Document generated by InfoPath. To be more specific, if any of the items in the Expense claim form were filed for a day in the weekend then we will send an email to &lt;i&gt;John the Expenses Manager&lt;/i&gt;. 
&lt;p&gt;Naturally this conditional logic could have been added inside the validation of the InfoPath form itself. However, that would require access to &lt;i&gt;Tom the InfoPath Expert&lt;/i&gt; and Tom is very busy and going on holiday tomorrow. In other words, we will need to be creative. 
&lt;p&gt;To create this workflow, carry out the following steps: 
&lt;ol&gt;
&lt;li&gt;We need to be able to access functionality in the &lt;i&gt;System.XML&lt;/i&gt; assembly. Add this reference to the relevant Web Application using the &lt;i&gt;Workflow Power Pack Central Administration&lt;/i&gt; screens as described in the &lt;a href="http://www.muhimbi.com/support/documentation/Workflow-Power-Pack/Administration-Guide.aspx"&gt;Administration guide&lt;/a&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;Make sure you have the appropriate privileges to create Form Libraries and design workflows on a site collection.&lt;br&gt;&amp;nbsp; &lt;li&gt;Open InfoPath, select &lt;i&gt;Customize a Sample&lt;/i&gt; followed by &lt;i&gt;Sample - Expense Report&lt;/i&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;Select &lt;i&gt;Publish&lt;/i&gt; from the &lt;i&gt;File&lt;/i&gt; menu, save the form anywhere on your local system and complete the wizard to publish it to a new Document Library named &lt;i&gt;Expense Forms&lt;/i&gt; in your site collection. There is no need to expose any columns to SharePoint.&lt;br&gt;&amp;nbsp; &lt;li&gt;In the &lt;i&gt;Expense Forms&lt;/i&gt; Document Library fill out the form, enter one expense in a weekend and make sure you save it to the Document Library. Don’t submit it as that will go via email.&lt;br&gt;&amp;nbsp; &lt;li&gt;Create a new workflow using SharePoint Designer.&lt;br&gt;&amp;nbsp; &lt;li&gt;On the Workflow definition screen associate the workflow with your new &lt;i&gt;Expense Forms&lt;/i&gt; Document Library, tick the two “automatically start” check boxes and proceed to the next screen.&lt;br&gt;&amp;nbsp; &lt;li&gt;Click the &lt;i&gt;Conditions&lt;/i&gt; button and insert the &lt;i&gt;Evaluate Custom Code &lt;/i&gt;&lt;i&gt;condition.&lt;br&gt;&amp;nbsp;&lt;/i&gt; 
&lt;li&gt;Insert the following C# based code by clicking &lt;u&gt;code&lt;/u&gt; and then the ellipsis (…) button.&lt;br&gt;&amp;nbsp;&lt;br&gt;
&lt;div style="padding-bottom: 8px; padding-left: 8px; padding-right: 8px; font-family: consolas; background: black; color: white; font-size: 8pt; font-weight: bold; padding-top: 8px"&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; System.Xml;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; System.IO;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Innocent until proven guilty&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;MyWorkflow.ReturnValue = &lt;span style="color: #cc7832"&gt;false&lt;/span&gt;; &lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;XmlDocument doc = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; XmlDocument();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Load the XML Form data out of the current item&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt;(Stream s = MyWorkflow.Item.File.OpenBinaryStream())&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; doc.Load(s); &lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Make sure we can query the namespaces properly.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; XmlNamespaceManager xnsm = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; XmlNamespaceManager(doc.NameTable);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xnsm.AddNamespace(&lt;span style="color: #a5c25c"&gt;"my"&lt;/span&gt;,&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #a5c25c"&gt;"http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-10-21T21:12:27"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Select all date nodes and iterate through them&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; XmlNodeList list = doc.SelectNodes(&lt;span style="color: #a5c25c"&gt;"//my:date"&lt;/span&gt;, xnsm);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;foreach&lt;/span&gt; (XmlNode node &lt;span style="color: #cc7832"&gt;in&lt;/span&gt; list) &lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Convert the date string to a real date&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #6897bb"&gt;DateTime&lt;/span&gt; expenseDate = &lt;span style="color: #6897bb"&gt;DateTime&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.ParseExact(node.InnerText, &lt;/span&gt;&lt;span style="color: #a5c25c"&gt;"yyyy-MM-dd"&lt;/span&gt;, &lt;span style="color: #cc7832"&gt;null&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;if&lt;/span&gt; (expenseDate.DayOfWeek == &lt;span style="color: #6897bb"&gt;DayOfWeek&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.Saturday ||&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; expenseDate.DayOfWeek == &lt;span style="color: #6897bb"&gt;DayOfWeek&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.Sunday)&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyWorkflow.ReturnValue = &lt;span style="color: #cc7832"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;/div&gt;&amp;nbsp; &lt;li&gt;Click the &lt;em&gt;Actions&lt;/em&gt; button and select the &lt;em&gt;Send an Email&lt;/em&gt; activity and fill in the blanks to make it send an email to the relevant manager. &lt;br&gt;&amp;nbsp; &lt;li&gt;Close the Workflow Designer and re-save the previously saved Expense Form to trigger the workflow. &lt;br&gt;&amp;nbsp;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="CheckExpense" border="0" alt="CheckExpense" src="http://lh6.ggpht.com/_IgJp5HQ80aU/SzDRJLstztI/AAAAAAAAAJk/qh_LBDQMJ1A/CheckExpense%5B6%5D.png?imgmax=800" width="571" height="300"&gt; 
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;&lt;font color="white"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-6825646643810692123?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/6825646643810692123/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2009/12/sharepoint-workflow-power-pack-user.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/6825646643810692123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/6825646643810692123'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2009/12/sharepoint-workflow-power-pack-user.html' title='SharePoint Workflow Power Pack User Guide - Embedding .net code in a Workflow Condition'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-2649520762851594653</id><published>2009-12-22T12:06:00.001Z</published><updated>2010-02-09T14:26:06.481Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='News'/><category scheme='http://www.blogger.com/atom/ns#' term='WPP'/><category scheme='http://www.blogger.com/atom/ns#' term='Products'/><category scheme='http://www.blogger.com/atom/ns#' term='Workflow'/><category scheme='http://www.blogger.com/atom/ns#' term='Articles'/><title type='text'>SharePoint Workflow Power Pack User Guide - Language Features</title><content type='html'>&lt;p&gt;&lt;img style="position: relative; border-right-width: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; margin-left: 15px; border-left-width: 0px; top: -23px; margin-right: 0px" title="User-Guide" border="0" alt="User-Guide" align="right" src="http://lh4.ggpht.com/_IgJp5HQ80aU/SzC2RBjbZoI/AAAAAAAAAJE/9y2D1YE1T8w/User-Guide%5B10%5D.jpg?imgmax=800" width="130" height="167"&gt;Even though we have only recently released the &lt;a href="http://www.muhimbi.com/blog/2009/12/embed-c-or-vb-code-directly-in.html"&gt;Muhimbi Workflow Power Pack for SharePoint&lt;/a&gt;, we are already getting good feedback from users. Most of the questions we get are already covered in the &lt;a href="http://www.muhimbi.com/support/documentation/Workflow-Power-Pack/User-Guide.aspx"&gt;User Guide&lt;/a&gt;, which is why we have decided to republish the user guide as a series of blog postings.&lt;/p&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2009/12/workflow-power-pack-user-guide-language.html';&lt;/script&gt;&lt;span style="margin-top: 3px; float: left; margin-right: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;A quick introduction In case you are not familiar with the product: &lt;em&gt;The Muhimbi Workflow Power Pack for SharePoint allows custom C# or VB.NET code to be embedded in SharePoint Designer Workflows without the need to resort to complex Visual Studio based workflows, the development of bespoke Workflow Activities or long development cycles.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;The following Blog postings are part of this User Guide series:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Language Features (this article): Discusses the &lt;em&gt;script like&lt;/em&gt; syntax, the generic workflow action and condition, passing parameters, returning values from a workflow and using the &lt;em&gt;MyWorkflow&lt;/em&gt; property.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/2009/12/sharepoint-workflow-power-pack-user.html"&gt;Embedding .net code in a Workflow Condition&lt;/a&gt;: Provides a number of examples of how to use the &lt;em&gt;Evaluate Custom Code&lt;/em&gt; condition to carry out basic as well as complex conditional tasks.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/2009/12/sharepoint-workflow-power-pack-user_22.html"&gt;Embedding .net code in a Workflow Action&lt;/a&gt;: Contains a number of examples of how to use the &lt;em&gt;Execute Custom Code&lt;/em&gt;&amp;nbsp; to basically carry out any action you can think of in a SharePoint Designer Workflow.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/2010/02/sharepoint-workflow-power-pack-user.html"&gt;Creating Custom Methods&lt;/a&gt;: Shows how to create your own methods in your scripts in order to keep the code organised and easy to maintain. &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;&amp;nbsp;&lt;br&gt; &lt;hr align="center" width="250"&gt; &lt;br&gt; &lt;p&gt;&amp;nbsp;&lt;br&gt;&lt;strong&gt;&lt;em&gt;Script Like&lt;/em&gt; Syntax&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;To allow code to be entered in an easy fashion, without needing to worry about namespaces, class or method names, the WPP takes a &lt;i&gt;script like&lt;/i&gt; approach. In essence the person designing the workflow can just enter a single line of code and the WPP will make sure it is wrapped in the appropriate class.  &lt;p&gt;Even though the traditional structure of a typical C# or VB.net file is not used, it is still possible to add shortcuts to namespaces by adding &lt;i&gt;Using&lt;/i&gt; (c#) or &lt;i&gt;Imports&lt;/i&gt; (VB) statements to the top of the code.&lt;/p&gt; &lt;p&gt;A simple C# code sample looks as follows:&lt;/p&gt; &lt;div style="padding-bottom: 8px; padding-left: 8px; padding-right: 8px; font-family: consolas; background: black; color: white; font-size: 8pt; font-weight: bold; padding-top: 8px"&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; System.Xml;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;XmlDocument doc = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; XmlDocument();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;doc.LoadXml(&lt;span style="color: #a5c25c"&gt;"&amp;lt;Test&amp;gt;Content&amp;lt;/Test&amp;gt;"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;MyWorkflow.ReturnValue = doc.SelectSingleNode(&lt;span style="color: #a5c25c"&gt;"//Test"&lt;/span&gt;).InnerText;&lt;/pre&gt;&lt;/div&gt;
&lt;p style="position: relative; top: -12px" align="center"&gt;&lt;br&gt;&lt;font size="1"&gt;&lt;em&gt;Note that in order to use System.XML, a reference will need to be added in Central Admin. For details see the &lt;a href="http://www.muhimbi.com/support/documentation/Workflow-Power-Pack/Administration-Guide.aspx"&gt;Administration Guide&lt;/a&gt;&lt;/em&gt;&lt;/font&gt; &lt;/p&gt;&lt;br&gt;
&lt;hr align="center" width="250"&gt;
&lt;br&gt;&lt;br&gt;
&lt;p&gt;&lt;strong&gt;Workflow Action Structure&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;When adding a new &lt;i&gt;Execute Custom Code &lt;/i&gt;action to a workflow you are presented with the following &lt;i&gt;workflow sentence&lt;/i&gt;. 
&lt;p&gt;&lt;img style="border-right-width: 0px; margin: 10px auto 5px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="ExecuteCustomCodeAction" border="0" alt="ExecuteCustomCodeAction" src="http://lh4.ggpht.com/_IgJp5HQ80aU/SzC2RtNhpOI/AAAAAAAAAJI/TTP57r8FNk0/ExecuteCustomCodeAction%5B6%5D.jpg?imgmax=800" width="595" height="57"&gt;&amp;nbsp;&lt;br&gt;The fields are as follows. 
&lt;table border="1" cellspacing="0" cellpadding="0" width="688"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="187"&gt;
&lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;Field&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="77"&gt;
&lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;Type&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="422"&gt;
&lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;Description&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="187"&gt;
&lt;p&gt;&lt;font size="2"&gt;this code&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="77"&gt;
&lt;p&gt;&lt;font size="2"&gt;Text&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="422"&gt;
&lt;p&gt;&lt;font size="2"&gt;The C# or VB.net code to execute.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="187"&gt;
&lt;p&gt;&lt;font size="2"&gt;Language&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="77"&gt;
&lt;p&gt;&lt;font size="2"&gt;C# or VB&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="422"&gt;
&lt;p&gt;&lt;font size="2"&gt;The language the code is written in.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="187"&gt;
&lt;p&gt;&lt;font size="2"&gt;parameter 1&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="77"&gt;
&lt;p&gt;&lt;font size="2"&gt;Object&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="422"&gt;
&lt;p&gt;&lt;font size="2"&gt;An optional parameter to pass to the workflow.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="187"&gt;
&lt;p&gt;&lt;font size="2"&gt;parameter 2&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="77"&gt;
&lt;p&gt;&lt;font size="2"&gt;Object&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="422"&gt;
&lt;p&gt;&lt;font size="2"&gt;Another optional parameter to pass to the workflow.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="187"&gt;
&lt;p&gt;&lt;font size="2"&gt;this variable&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="77"&gt;
&lt;p&gt;&lt;font size="2"&gt;Object&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="422"&gt;
&lt;p&gt;&lt;font size="2"&gt;An optional workflow parameter to fill with the result.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="187"&gt;
&lt;p&gt;&lt;font size="2"&gt;Enter an optional comment&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="77"&gt;
&lt;p&gt;&lt;font size="2"&gt;Text&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="422"&gt;
&lt;p&gt;&lt;font size="2"&gt;An optional summary of what the code does.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;br&gt;&lt;br&gt;
&lt;hr align="center" width="250"&gt;
&lt;br&gt;&lt;br&gt;
&lt;p&gt;&lt;strong&gt;Workflow Condition structure&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;When adding an &lt;i&gt;Evaluate Custom Code Condition &lt;/i&gt;to a workflow, you are presented with the following. 
&lt;p&gt;&lt;img style="border-right-width: 0px; margin: 10px auto 5px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="ExecuteCustomCodeCondition" border="0" alt="ExecuteCustomCodeCondition" src="http://lh6.ggpht.com/_IgJp5HQ80aU/SzC2R1WiD7I/AAAAAAAAAJM/sf9ZzQgXmuU/ExecuteCustomCodeCondition%5B6%5D.jpg?imgmax=800" width="595" height="57"&gt; 
&lt;p&gt;The fields are as follows. 
&lt;table border="1" cellspacing="0" cellpadding="0" width="688"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="186"&gt;
&lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;Field&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="78"&gt;
&lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;Type&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="420"&gt;
&lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;Description&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="186"&gt;
&lt;p&gt;&lt;font size="2"&gt;this code&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="78"&gt;
&lt;p&gt;&lt;font size="2"&gt;Text&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="420"&gt;
&lt;p&gt;&lt;font size="2"&gt;The C# or VB.net code to execute.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="186"&gt;
&lt;p&gt;&lt;font size="2"&gt;Language&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="78"&gt;
&lt;p&gt;&lt;font size="2"&gt;C# or VB&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="420"&gt;
&lt;p&gt;&lt;font size="2"&gt;The language the code is written in.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="186"&gt;
&lt;p&gt;&lt;font size="2"&gt;parameter 1&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="78"&gt;
&lt;p&gt;&lt;font size="2"&gt;Object&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="420"&gt;
&lt;p&gt;&lt;font size="2"&gt;An optional parameter to pass to the condition.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="186"&gt;
&lt;p&gt;&lt;font size="2"&gt;parameter 2&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="78"&gt;
&lt;p&gt;&lt;font size="2"&gt;Object&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="420"&gt;
&lt;p&gt;&lt;font size="2"&gt;Another optional parameter to pass to the condition.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="186"&gt;
&lt;p&gt;&lt;font size="2"&gt;Enter an optional comment&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="78"&gt;
&lt;p&gt;&lt;font size="2"&gt;Text&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="420"&gt;
&lt;p&gt;&lt;font size="2"&gt;An optional summary of what the code does.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;A condition should always evaluate to either &lt;i&gt;True&lt;/i&gt; or &lt;i&gt;False&lt;/i&gt;.&amp;nbsp; &lt;/p&gt;&lt;br&gt;&lt;br&gt;
&lt;hr align="center" width="250"&gt;
&lt;br&gt;&lt;br&gt;&lt;br&gt;
&lt;p&gt;&lt;strong&gt;Passing values and Parameters&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Workflow parameters and other values can be passed to the custom code in a number of ways.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Parameter 1 &amp;amp; 2:&lt;/b&gt; Use the Parameter 1 &amp;amp; 2 variables to pass a constant, workflow variable or any other kind of &lt;i&gt;Workflow Lookup value&lt;/i&gt;. Note that these values are passed as type &lt;i&gt;Object&lt;/i&gt; and may need to be cast into the correct data type in your code. 
&lt;p&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="DefineWorkflowLookup" border="0" alt="DefineWorkflowLookup" src="http://lh4.ggpht.com/_IgJp5HQ80aU/SzC2Sqe95cI/AAAAAAAAAJQ/QZiYGTUWs5E/DefineWorkflowLookup%5B7%5D.jpg?imgmax=800" width="383" height="162"&gt; 
&lt;p&gt;The Parameter1 and Parameter2 values can be accessed from the custom code using the &lt;i&gt;MyWorkflow&lt;/i&gt; variable. For details see &lt;em&gt;Using the MyWorkflow &lt;/em&gt;section below. 
&lt;p&gt;&lt;b&gt;&lt;/b&gt;&amp;nbsp; &lt;p&gt;&lt;b&gt;Embedding Workflow Lookup variables:&lt;/b&gt; Workflow Actions allow lookup variables to be directly embedded into the source code using the &lt;i&gt;Add Lookup&lt;/i&gt; button. 
&lt;p&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="LookupVariables" border="0" alt="LookupVariables" src="http://lh5.ggpht.com/_IgJp5HQ80aU/SzC2S5g9hVI/AAAAAAAAAJU/9CxZgMRwrsY/LookupVariables%5B12%5D.png?imgmax=800" width="504" height="343"&gt; 
&lt;p&gt;At runtime all lookup variables are placed into the code as text, so please make sure that the generated syntax is still valid. 
&lt;p&gt;For example, the following code will not execute correctly: 
&lt;p&gt;&lt;font size="2" face="Courier New"&gt;&amp;nbsp;&amp;nbsp; String name = &lt;u&gt;[%Variable: firstName%]&lt;/u&gt;;&lt;/font&gt; 
&lt;p&gt;As this may result in the following code: 
&lt;p&gt;&lt;font size="2" face="Courier New"&gt;&amp;nbsp;&amp;nbsp; String name = John;&lt;/font&gt; 
&lt;p&gt;&amp;nbsp; &lt;p&gt;To solve this problem, add quotes around the variable as follows: 
&lt;p&gt;&lt;font size="2" face="Courier New"&gt;&amp;nbsp;&amp;nbsp; String name = "&lt;u&gt;[%Variable: firstName%]&lt;/u&gt;";&lt;/font&gt; 
&lt;p&gt;Which will result in to following, syntactically correct, code: 
&lt;p&gt;&lt;font size="2" face="Courier New"&gt;&amp;nbsp;&amp;nbsp; String name = "John";&lt;/font&gt; 
&lt;p&gt;&amp;nbsp; &lt;p&gt;Note that SharePoint does not allow Workflow Lookups to be defined in the code for Custom Conditions as these are handled differently inside the workflow execution engine. &lt;/p&gt;&lt;br&gt;&lt;br&gt;
&lt;hr align="center" width="250"&gt;
&lt;br&gt;&lt;br&gt;&lt;br&gt;
&lt;p&gt;&lt;strong&gt;Returning Values&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Variables or result values can be returned from your custom code by using the &lt;font size="2" face="Courier New"&gt;MyWorkflow.ReturnValue&lt;/font&gt; property. 
&lt;p&gt;Returning values using the &lt;font size="2" face="Courier New"&gt;return&lt;/font&gt; statement is not supported. &lt;/p&gt;&lt;br&gt;&lt;br&gt;
&lt;hr align="center" width="250"&gt;
&lt;br&gt;&lt;br&gt;&lt;br&gt;
&lt;p&gt;&lt;strong&gt;Using the &lt;em&gt;MyWorkflow&lt;/em&gt; property&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;When developing workflows you frequently need access to data related to the workflow. To make accessing this data easy you can access the &lt;i&gt;MyWorkflow&lt;/i&gt; property from your own code. 
&lt;p&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="MyWorkflowType" border="0" alt="MyWorkflowType" src="http://lh3.ggpht.com/_IgJp5HQ80aU/SzC2TCWSZTI/AAAAAAAAAJY/xneCsQGs0LQ/MyWorkflowType%5B7%5D.png?imgmax=800" width="331" height="276"&gt; 
&lt;div style="position: relative; top: -32px" align="center"&gt;&lt;br&gt;&lt;font size="1"&gt;&lt;em&gt;MyWorkflow underlying type&lt;/em&gt;&lt;/font&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The &lt;i&gt;MyWorkflow&lt;/i&gt; property has the following fields.&lt;/p&gt;
&lt;p&gt;
&lt;table border="1" cellspacing="0" cellpadding="0" width="688"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="138"&gt;
&lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;Field&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="136"&gt;
&lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;Type&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="381"&gt;
&lt;p&gt;&lt;b&gt;&lt;font size="2"&gt;Description&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="138"&gt;
&lt;p&gt;&lt;font size="2"&gt;ActivityExecutionContext&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="136"&gt;
&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.workflow.componentmodel.activityexecutioncontext_members.aspx"&gt;&lt;font size="2"&gt;ActivityExecutionContext&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="381"&gt;
&lt;p&gt;&lt;font size="2"&gt;Represents the execution environment of an Activity. This class selectively exposes workflow runtime capabilities and services to individual activities.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="138"&gt;
&lt;p&gt;&lt;font size="2"&gt;Item&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="136"&gt;
&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistitem.aspx"&gt;&lt;font size="2"&gt;SPListItem&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="381"&gt;
&lt;p&gt;&lt;font size="2"&gt;Reference to the item the current workflow is acting on.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="138"&gt;
&lt;p&gt;&lt;font size="2"&gt;List&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="136"&gt;
&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splist.aspx"&gt;&lt;font size="2"&gt;SPList&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="381"&gt;
&lt;p&gt;&lt;font size="2"&gt;Reference to the SharePoint list the current item is located in.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="138"&gt;
&lt;p&gt;&lt;font size="2"&gt;Parameter1&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="136"&gt;
&lt;p&gt;&lt;font size="2"&gt;Object&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="381"&gt;
&lt;p&gt;&lt;font size="2"&gt;The first, optional, parameter passed in by the workflow. &lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="138"&gt;
&lt;p&gt;&lt;font size="2"&gt;Parameter2&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="136"&gt;
&lt;p&gt;&lt;font size="2"&gt;Object&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="381"&gt;
&lt;p&gt;&lt;font size="2"&gt;The second, optional, parameter passed in by the workflow.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="138"&gt;
&lt;p&gt;&lt;font size="2"&gt;Site&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="136"&gt;
&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsite.aspx"&gt;&lt;font size="2"&gt;SPSite&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="381"&gt;
&lt;p&gt;&lt;font size="2"&gt;Reference to the site collection the workflow is located in.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="138"&gt;
&lt;p&gt;&lt;font size="2"&gt;Web&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="136"&gt;
&lt;p&gt;&lt;font size="2"&gt;SPWeb&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="381"&gt;
&lt;p&gt;&lt;font size="2"&gt;Reference to the site the workflow is located in.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="138"&gt;
&lt;p&gt;&lt;font size="2"&gt;WorkflowContext&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="136"&gt;
&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.workflowactions.workflowcontext_members.aspx"&gt;&lt;font size="2"&gt;WorkflowContext&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="381"&gt;
&lt;p&gt;&lt;font size="2"&gt;Reference to the SharePoint workflow Context.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="138"&gt;
&lt;p&gt;&lt;font size="2"&gt;WorkflowInstanceId&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="136"&gt;
&lt;p&gt;&lt;font size="2"&gt;Guid&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="381"&gt;
&lt;p&gt;&lt;font size="2"&gt;The ID of the current workflow instance.&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &lt;p&gt;The following code illustrates how to use some of the &lt;i&gt;MyWorkflow&lt;/i&gt; fields from your own code. &lt;/p&gt;
&lt;div style="padding-bottom: 8px; padding-left: 8px; padding-right: 8px; font-family: consolas; background: black; color: white; font-size: 8pt; font-weight: bold; padding-top: 8px"&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; System.Workflow.ComponentModel;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; Microsoft.SharePoint.Workflow;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Concatenate the strings&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #ffc66d"&gt;String&lt;/span&gt; message = &lt;span style="color: #ffc66d"&gt;String&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.Format(&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #a5c25c"&gt;"SPSite: {0} - SPWeb: {1} - SPList: {2} - Item: {3} - P1: {4} - P2: {5} - User: {6}"&lt;/span&gt;, &lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyWorkflow.Site.ServerRelativeUrl, MyWorkflow.Web.Title, MyWorkflow.List.Title, &lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyWorkflow.Item.Title, MyWorkflow.Parameter1, MyWorkflow.Parameter2, &lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyWorkflow.Web.CurrentUser.LoginName);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Log to the workflow history&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;ISharePointService service = (ISharePointService)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyWorkflow.ActivityExecutionContext.GetService(&lt;span style="color: #cc7832"&gt;typeof&lt;/span&gt;(ISharePointService));&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;service.LogToHistoryList(MyWorkflow.WorkflowInstanceId, SPWorkflowHistoryEventType.None, &lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #6897bb"&gt;0&lt;/span&gt;, &lt;span style="color: #6897bb"&gt;TimeSpan&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.MinValue, &lt;/span&gt;&lt;span style="color: #a5c25c"&gt;""&lt;/span&gt;, message, message);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: gray"&gt;// ** Pass the message back to the workflow for further processing&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;MyWorkflow.ReturnValue = message;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This is just an example. Rather than logging to the workflow history from your own code, you could simply pass the &lt;i&gt;ReturnValue&lt;/i&gt; into a standard SharePoint Designer &lt;i&gt;Log to History List &lt;/i&gt;activity. 
&lt;p&gt;&lt;font color="white"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-2649520762851594653?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/2649520762851594653/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2009/12/workflow-power-pack-user-guide-language.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/2649520762851594653'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/2649520762851594653'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2009/12/workflow-power-pack-user-guide-language.html' title='SharePoint Workflow Power Pack User Guide - Language Features'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-2276470800820045756</id><published>2009-12-21T10:40:00.001Z</published><updated>2009-12-21T13:19:26.162Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='News'/><category scheme='http://www.blogger.com/atom/ns#' term='WPP'/><category scheme='http://www.blogger.com/atom/ns#' term='Products'/><category scheme='http://www.blogger.com/atom/ns#' term='Workflow'/><category scheme='http://www.blogger.com/atom/ns#' term='Articles'/><title type='text'>Embed C# or VB code in SharePoint Designer Workflows using the Workflow Power Pack</title><content type='html'>&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="WPPBox" border="0" alt="WPPBox" align="right" src="http://lh3.ggpht.com/_IgJp5HQ80aU/Sy9Qj9vcY0I/AAAAAAAAAI4/7ARF5BVoulg/WPPBox%5B5%5D.jpg?imgmax=800" width="200" height="183"&gt;&lt;/p&gt; &lt;p&gt;One of our customers recently wrote in a support email “&lt;em&gt;If only Microsoft allowed C# code to be used in SharePoint Designer workflows, my life would be so much easier&lt;/em&gt;”. Little did this person know that we were in the middle of a development cycle to make his wish come true, just in time for Christmas as well.&lt;/p&gt; &lt;p&gt;The &lt;a href="http://www.muhimbi.com/Products/Workflow-Power-Pack-for-SharePoint.aspx"&gt;Muhimbi Workflow Power Pack for SharePoint&lt;/a&gt; allows custom C# or VB.NET code to be embedded in SharePoint Designer Workflows without the need to resort to complex Visual Studio based workflows, the development of bespoke Workflow Activities or long development cycles.&lt;/p&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2009/12/embed-c-or-vb-code-directly-in.html';&lt;/script&gt;&lt;span style="margin-top: 3px; float: left; margin-right: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;What does this mean for day-to-day SharePoint Designer Workflow development? When Microsoft released SharePoint 2007, they included a basic set of Workflow Actions and Conditions to allow basic comparison of values and simple tasks such as setting a field value or logging to the Workflow History. If you wanted to do anything else your options were limited to expensive third party workflow tools that would hopefully support the functionality you are after, or writing your own solution in Visual Studio.&lt;/p&gt; &lt;p&gt;From as little as $349, the Workflow Power Pack is the last 3rd party workflow solution you’ll ever need. The possibilities are only limited by your own imagination, for example:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Carry out tasks by comparing deeply nested XML data inside InfoPath forms.  &lt;li&gt;Create Actions that directly access SQL Databases or other common data sources.  &lt;li&gt;Make string, date and numerical operations simple (Finally!).  &lt;li&gt;Access any SharePoint functionality using the SharePoint Object Model.  &lt;li&gt;Send emails and includie attachments.  &lt;li&gt;Create folders in the current SharePoint List or any other list regardless of Site Collection.  &lt;li&gt;Control security on individual List Items or entire Document Libraries.  &lt;li&gt;Invoke web services or any 1st or 3rd party assembly, for example our &lt;a href="http://www.muhimbi.com/Products/PDF-Converter-for-SharePoint/Summary.aspx"&gt;PDF Converter for SharePoint&lt;/a&gt; or &lt;a href="http://www.muhimbi.com/Products/SharePoint-URL-Shortener/Summary.aspx"&gt;URL Shortener for SharePoint&lt;/a&gt;. &lt;br&gt;&amp;nbsp;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;The list goes on and on. Basically, if it exposes a .net interface, you can access it using the Workflow Power Pack.&lt;br&gt;&amp;nbsp;&lt;/p&gt; &lt;p align="center"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Screenshot-SharePointDesigner450x300" border="0" alt="Screenshot-SharePointDesigner450x300" src="http://lh3.ggpht.com/_IgJp5HQ80aU/Sy9QkdGSNGI/AAAAAAAAAI8/WNoBMxYi1XA/Screenshot-SharePointDesigner450x300%5B6%5D.jpg?imgmax=800" width="470" height="320"&gt;&amp;nbsp;&lt;em&gt;&lt;font size="1"&gt;Embed C# or VB.net code directly into your SharePoint Designer Workflow&lt;/font&gt;&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;br&gt;Key features:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Embed C# or VB code in SharePoint Designer Workflow Conditions.&lt;br&gt;&amp;nbsp; &lt;li&gt;Embed C# or VB code in SharePoint Designer Workflow Actions.&lt;br&gt;&amp;nbsp; &lt;li&gt;Easily access the Workflow context using the MyWorkflow property.&lt;br&gt;&amp;nbsp; &lt;li&gt;Easily pass workflow parameters in and out of the custom code.&lt;br&gt;&amp;nbsp; &lt;li&gt;Secure the system by controlling access to the assemblies that can be used.&lt;br&gt;&amp;nbsp; &lt;li&gt;Comes with comprehensive documentation and access to a professional and responsive support desk.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p align="center"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Screenshot-CentralAdmin450" border="0" alt="Screenshot-CentralAdmin450" src="http://lh4.ggpht.com/_IgJp5HQ80aU/Sy9Qkp4qluI/AAAAAAAAAJA/Hq0s7DxfahU/Screenshot-CentralAdmin450%5B6%5D.jpg?imgmax=800" width="470" height="452"&gt;&amp;nbsp;&lt;em&gt;&lt;font size="1"&gt;Secure your system by controlling which Assemblies can be accessed&lt;/font&gt;&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;br&gt;For more information check out the following resources:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://www.muhimbi.com/Products/Workflow-Power-Pack-for-SharePoint.aspx"&gt;Product Page&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/documentation/Workflow-Power-Pack/Release-Notes.aspx"&gt;Release Notes&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/documentation/Workflow-Power-Pack/Administration-Guide.aspx"&gt;Administration Guide&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/documentation/Workflow-Power-Pack/User-Guide.aspx"&gt;User Guide&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/documentation/Workflow-Power-Pack/Screenshots.aspx"&gt;Screenshots&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/faqs.aspx"&gt;FAQ&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/support/forum.aspx"&gt;Message Board&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://www.muhimbi.com/blog/labels/WPP.html"&gt;All Workflow Power Pack related Blog postings&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&amp;nbsp;&lt;br&gt;As always, feel free to &lt;a href="http://www.muhimbi.com/contact.aspx"&gt;contact us using Twitter, our Blog, regular email&lt;/a&gt; or &lt;a href="http://eepurl.com/b6A7"&gt;subscribe to our newsletter&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p align="center"&gt;&lt;a href="http://www.muhimbi.com/Products/Workflow-Power-Pack-for-SharePoint/Download.aspx"&gt;Download your free trial here&lt;/a&gt; (1MB). &lt;/p&gt; &lt;p&gt;&lt;font color="white"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-2276470800820045756?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/2276470800820045756/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2009/12/embed-c-or-vb-code-directly-in.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/2276470800820045756'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/2276470800820045756'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2009/12/embed-c-or-vb-code-directly-in.html' title='Embed C# or VB code in SharePoint Designer Workflows using the Workflow Power Pack'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5787751540548761056.post-2966746172252397569</id><published>2009-12-02T16:44:00.001Z</published><updated>2010-03-05T13:53:52.229Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='News'/><category scheme='http://www.blogger.com/atom/ns#' term='Products'/><category scheme='http://www.blogger.com/atom/ns#' term='PDF Converter'/><category scheme='http://www.blogger.com/atom/ns#' term='Articles'/><title type='text'>Converting Office files to PDF Format using a Web Services based interface</title><content type='html'>&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="Web-Services-Icon" border="0" alt="Web-Services-Icon" align="right" src="http://lh6.ggpht.com/_IgJp5HQ80aU/SxaZZEkHiWI/AAAAAAAAAIk/-upLLdMJPI4/Web-Services-Icon%5B5%5D.jpg?imgmax=800" width="140" height="161"&gt; One of the key changes introduced with the release of the &lt;a href="http://muhimbi.com/Products/PDF-Converter-for-SharePoint.aspx"&gt;Muhimbi PDF Converter Service 3.0&lt;/a&gt; is the ability to convert typical Office files via a web services based interface. Although we mainly target the SharePoint market, there is no reason why you can’t just install the Muhimbi Document Converter&amp;nbsp; Service (MDCS) on your server and access it from your own .NET or Java solution using a web services based interface.&lt;/p&gt;&lt;script type="text/javascript"&gt;tweetmeme_url = 'http://www.muhimbi.com/blog/2009/12/converting-office-files-to-pdf-format.html';&lt;/script&gt;&lt;span style="margin-top: 3px; float: left; margin-right: 5px"&gt;&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/span&gt; &lt;p&gt;This post describes the key features of our web services based interface and provides a simple example of how to use it to convert a document to PDF format. Source code for a more comprehensive demo is available for download as well. Feel free to &lt;a href="http://muhimbi.com/contact.aspx"&gt;contact us&lt;/a&gt; if you have any questions.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Let’s make sure all prerequisites are in place before we start our tutorial. &lt;/p&gt; &lt;ol&gt; &lt;li&gt;Download the &lt;a href="http://muhimbi.com/Products/PDF-Converter-for-SharePoint/Free-Trial.aspx"&gt;PDF Converter&lt;/a&gt;. &lt;br&gt;&amp;nbsp; &lt;li&gt;Install it in-line with chapter 2 of the included &lt;a href="http://muhimbi.com/support/documentation/PDF-Converter-for-SharePoint/Administration-Guide.aspx"&gt;Administration Guide&lt;/a&gt;. &lt;br&gt;&amp;nbsp; &lt;li&gt;Note that if you are not using it in combination with SharePoint or on a machine that does not have SharePoint installed then:&lt;br&gt;&amp;nbsp; &lt;ul&gt; &lt;li&gt;there is no need to install&amp;nbsp; the SharePoint Front End. &lt;br&gt;&amp;nbsp; &lt;li&gt;you need to change the group names used for authentication as per section 2.3.2 of the Administration Guide.&lt;/li&gt;&lt;/ul&gt;&amp;nbsp; &lt;br&gt;&amp;nbsp;&lt;br&gt;&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;strong&gt;Key Features&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Key Features of the Muhimbi Document Conversion Service are:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Convert popular document types to PDF or XPS format with near perfect fidelity. At the time of writing support is available for MS-Word, PowerPoint, Excel, InfoPath and MS-Publisher, but by the time you are reading this additional document formats may have been added.&lt;br&gt;&amp;nbsp; &lt;li&gt;Scalable architecture that allows multiple conversions to run in parallel.&lt;br&gt;&amp;nbsp; &lt;li&gt;Runs as a Windows Service. No need to install or configure IIS or other web service frameworks.&lt;br&gt;&amp;nbsp; &lt;li&gt;Convert password protected documents.&lt;br&gt;&amp;nbsp; &lt;li&gt;Apply security settings to generated PDF files including encryption, password protection and multiple levels of PDF Security options to prevent users from printing documents or copy a document’s content.&lt;br&gt;&amp;nbsp; &lt;li&gt;Generate a regular PDF file or a file in PDF/A format.&lt;br&gt;&amp;nbsp; &lt;li&gt;Generate high resolution PDF Files optimised for printing or normal resolution files optimised for use on screen.&lt;br&gt;&amp;nbsp; &lt;li&gt;Dynamically refresh a document’s content before generating the PDF. Ideal for &lt;a href="http://www.muhimbi.com/blog/2009/09/inserting-sharepoint-list-data-into-pdf.html"&gt;merging content from SharePoint custom columns into your PDF file&lt;/a&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;Control how to deal with hidden / selected content such as PowerPoint Slides and Excel worksheets.&lt;br&gt;&amp;nbsp;&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;In addition to the features described above, the MDCS software stack also contains a layer of functionality to control concurrency, request queuing and watchdog services to deal with unresponsive and runaway processes. More detail can be found in &lt;a href="http://muhimbi.com/Images---Files/PDFConverter/PDF-Converter-Brochure.aspx"&gt;the brochure&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&amp;nbsp;&lt;br&gt;Object Model&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Although the Object Model exposed by the web service is easy to understand, the system provides very powerful functionality and fine grained control to specify how the PDF file is generated.&lt;/p&gt; &lt;p&gt;As outlined in the image below, the web service contains 3 methods:&lt;br&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="PDF-Converter-Web-Services-Main-Interface" border="0" alt="PDF-Converter-Web-Services-Main-Interface" src="http://lh4.ggpht.com/_IgJp5HQ80aU/SxaZZWXk2XI/AAAAAAAAAIo/nFxrR0ajbi4/PDF-Converter-Web-Services-Main-Interface%5B7%5D.png?imgmax=800" width="584" height="131"&gt;&amp;nbsp; &lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;Convert:&lt;/strong&gt; Convert the file in the &lt;em&gt;sourceFile &lt;/em&gt;byte array using the specified &lt;em&gt;openOptions&lt;/em&gt; and &lt;em&gt;conversionSettings&lt;/em&gt;. The generated PDF or XPS file is returned as a byte array as well.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;strong&gt;GetConfiguration:&lt;/strong&gt; Retrieve information about which converters are supported and the associated file extensions. Consider calling this service once to retrieve a list of valid file extensions and check if a file is supported before it is submit to the web service. This will prevent a lot of redundant traffic and will increase scalability.&lt;br&gt;&amp;nbsp; &lt;li&gt;&lt;strong&gt;GetDiagnostics:&lt;/strong&gt; Run a diagnostics test that carries out an internal end-to-end test for each supported document type. Call this method to check if the service and all prerequisites have been deployed correctly.&lt;br&gt;&amp;nbsp;&lt;br&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;The full object model is available in the following diagram. Click to enlarge it. &lt;br&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_IgJp5HQ80aU/SxaZaESCEYI/AAAAAAAAAIs/VYX0uCCcc-8/s1600-h/PDF-Converter-Web-Services-Class-Diagram%5B13%5D.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="PDF-Converter-Web-Services-Class-Diagram" border="0" alt="PDF-Converter-Web-Services-Class-Diagram" src="http://lh6.ggpht.com/_IgJp5HQ80aU/SxaZa-iINGI/AAAAAAAAAIw/-BQNnnGC64M/PDF-Converter-Web-Services-Class-Diagram_thumb%5B11%5D.png?imgmax=800" width="700" height="532"&gt;&lt;/a&gt;&lt;br&gt; &lt;div style="position: relative; text-align: center; font-size: 8pt; top: -17px"&gt;&lt;i&gt;PDF Converter Web Service Class Diagram. Click to enlarge.&lt;/i&gt;&lt;/div&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Simple example code&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;The following sample shows the minimum steps required to convert a document to PDF format. In our example we are using Visual Studio and C#, but any environment that can invoke web services should be able to access the required functionality. Note that the WSDL can be found at &lt;em&gt;http://localhost:41734/Muhimbi.DocumentConverter.WebService/?wsdl&lt;/em&gt;.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Start a new Visual Studio project and use the project type of your choice. In this example we are using a standard &lt;em&gt;.net 3.0 &lt;/em&gt;project of type &lt;em&gt;Windows Forms Application&lt;/em&gt;. Name it ‘Simple PDF Converter Sample’.&lt;br&gt;&amp;nbsp; &lt;li&gt;Add a TextBox and Button control button to the form. Accept the default names of &lt;em&gt;textBox1&lt;/em&gt; and &lt;em&gt;button1&lt;/em&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;In the &lt;em&gt;Solution Explorer&lt;/em&gt; window, right-click &lt;em&gt;References&lt;/em&gt; and select &lt;em&gt;Add Service Reference&lt;/em&gt;.&lt;br&gt;&amp;nbsp; &lt;li&gt;In the &lt;em&gt;Address&lt;/em&gt; box enter the WSDL address listed in the introduction of this section. If the MDCS is located on a different machine then substitute &lt;em&gt;localhost&lt;/em&gt; with the server’s name. &lt;br&gt;&amp;nbsp; &lt;li&gt;Accept the default Namespace of &lt;em&gt;ServiceReference1&lt;/em&gt; and click the &lt;em&gt;OK&lt;/em&gt; button to generate the proxy classes.&lt;br&gt;&amp;nbsp; &lt;li&gt;Double click &lt;em&gt;Button1&lt;/em&gt; and replace the content of the entire code file with the following:&lt;br&gt;&amp;nbsp;&lt;br&gt;&amp;nbsp; &lt;/li&gt;&lt;/ol&gt; &lt;div style="padding-bottom: 4px; padding-left: 4px; padding-right: 4px; font-family: consolas; background: black; color: white; font-size: 8pt; font-weight: bold; padding-top: 4px"&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; System;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; System.IO;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; System.ServiceModel;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; System.Windows.Forms;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;using&lt;/span&gt; Simple_PDF_Converter_Sample.ServiceReference1;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: #cc7832"&gt;namespace&lt;/span&gt; Simple_PDF_Converter_Sample&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;public&lt;/span&gt; &lt;span style="color: #cc7832"&gt;partial&lt;/span&gt; &lt;span style="color: #cc7832"&gt;class&lt;/span&gt; &lt;span style="color: #ffc66d"&gt;Form1&lt;/span&gt; : &lt;span style="color: #ffc66d"&gt;Form&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** The URL where the Web Service is located. Amend host name if needed.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;string&lt;/span&gt; SERVICE_URL = &lt;span style="color: #a5c25c"&gt;"http://localhost:41734/Muhimbi.DocumentConverter.WebService/"&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;public&lt;/span&gt; Form1()&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InitializeComponent();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;private&lt;/span&gt; &lt;span style="color: #cc7832"&gt;void&lt;/span&gt; button1_Click(&lt;span style="color: #cc7832"&gt;object&lt;/span&gt; sender, &lt;span style="color: #ffc66d"&gt;EventArgs&lt;/span&gt; e)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #ffc66d"&gt;DocumentConverterServiceClient&lt;/span&gt; client = &lt;span style="color: #cc7832"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;try&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Determine the source file and read it into a byte array.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;string&lt;/span&gt; sourceFileName = textBox1.Text;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;byte&lt;/span&gt;[] sourceFile = &lt;span style="color: #ffc66d"&gt;File&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.ReadAllBytes(sourceFileName);&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Open the service and configure the bindings&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; client = OpenService(SERVICE_URL);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;//** Set the absolute minimum open options&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #ffc66d"&gt;OpenOptions&lt;/span&gt; openOptions = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; &lt;span style="color: #ffc66d"&gt;OpenOptions&lt;/span&gt;();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; openOptions.OriginalFileName = &lt;span style="color: #ffc66d"&gt;Path&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.GetFileName(sourceFileName);&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; openOptions.FileExtension = &lt;span style="color: #ffc66d"&gt;Path&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.GetExtension(sourceFileName);&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Set the absolute minimum conversion settings.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #ffc66d"&gt;ConversionSettings&lt;/span&gt; conversionSettings = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; &lt;span style="color: #ffc66d"&gt;ConversionSettings&lt;/span&gt;();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conversionSettings.Fidelity = &lt;span style="color: #6897bb"&gt;ConversionFidelities&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.Full;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conversionSettings.Quality = &lt;span style="color: #6897bb"&gt;ConversionQuality&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.OptimizeForPrint;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Carry out the conversion.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;byte&lt;/span&gt;[] convFile = client.Convert(sourceFile, openOptions, conversionSettings);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Write the converted file back to the file system with a PDF extension.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;string&lt;/span&gt; destinationFileName = &lt;span style="color: #ffc66d"&gt;Path&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.GetDirectoryName(sourceFileName) + &lt;/span&gt;&lt;span style="color: #eb6767; font-weight: normal"&gt;@"\"&lt;/span&gt; +&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #ffc66d"&gt;Path&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.GetFileNameWithoutExtension(sourceFileName) +&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #a5c25c"&gt;"."&lt;/span&gt; + conversionSettings.Format;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;using&lt;/span&gt; (&lt;span style="color: #ffc66d"&gt;FileStream&lt;/span&gt; fs = &lt;span style="color: #ffc66d"&gt;File&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.Create(destinationFileName))&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fs.Write(convFile, &lt;span style="color: #6897bb"&gt;0&lt;/span&gt;, convFile.Length);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fs.Close();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #ffc66d"&gt;MessageBox&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.Show(&lt;/span&gt;&lt;span style="color: #a5c25c"&gt;"File converted to "&lt;/span&gt; + destinationFileName);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;catch&lt;/span&gt; (&lt;span style="color: #ffc66d"&gt;FaultException&lt;/span&gt;&lt;span style="font-weight: normal"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #ffc66d"&gt;WebServiceFaultException&lt;/span&gt;&lt;span style="font-weight: normal"&gt;&amp;gt; ex)&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #ffc66d"&gt;MessageBox&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.Show(&lt;/span&gt;&lt;span style="color: #a5c25c"&gt;"FaultException occurred: ExceptionType: "&lt;/span&gt; + &lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ex.Detail.ExceptionType.ToString());&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;catch&lt;/span&gt; (&lt;span style="color: #ffc66d"&gt;Exception&lt;/span&gt; ex)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #ffc66d"&gt;MessageBox&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.Show(ex.ToString());&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;finally&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CloseService(client);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; Configure the Bindings, endpoints and open the service using the specified address.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;An instance of the Web Service.&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;public&lt;/span&gt; &lt;span style="color: #cc7832"&gt;static&lt;/span&gt; &lt;span style="color: #ffc66d"&gt;DocumentConverterServiceClient&lt;/span&gt; OpenService(&lt;span style="color: #cc7832"&gt;string&lt;/span&gt; address)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #ffc66d"&gt;DocumentConverterServiceClient&lt;/span&gt; client = &lt;span style="color: #cc7832"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;try&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #ffc66d"&gt;BasicHttpBinding&lt;/span&gt; binding = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; &lt;span style="color: #ffc66d"&gt;BasicHttpBinding&lt;/span&gt;();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Use standard Windows Security.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding.Security.Mode = &lt;span style="color: #6897bb"&gt;BasicHttpSecurityMode&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.TransportCredentialOnly;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding.Security.Transport.ClientCredentialType = &lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #6897bb"&gt;HttpClientCredentialType&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.Windows;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Increase the Timeout to deal with (very) long running requests.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding.SendTimeout = &lt;span style="color: #6897bb"&gt;TimeSpan&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.FromMinutes(&lt;/span&gt;&lt;span style="color: #6897bb"&gt;30&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding.ReceiveTimeout = &lt;span style="color: #6897bb"&gt;TimeSpan&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.FromMinutes(&lt;/span&gt;&lt;span style="color: #6897bb"&gt;30&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Set the maximum document size to 40MB&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding.MaxReceivedMessageSize = &lt;span style="color: #6897bb"&gt;50&lt;/span&gt;&lt;span style="font-weight: normal"&gt;*&lt;/span&gt;&lt;span style="color: #6897bb"&gt;1024&lt;/span&gt;&lt;span style="font-weight: normal"&gt;*&lt;/span&gt;&lt;span style="color: #6897bb"&gt;1024&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding.ReaderQuotas.MaxArrayLength = &lt;span style="color: #6897bb"&gt;50&lt;/span&gt; * &lt;span style="color: #6897bb"&gt;1024&lt;/span&gt; * &lt;span style="color: #6897bb"&gt;1024&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding.ReaderQuotas.MaxStringContentLength = &lt;span style="color: #6897bb"&gt;50&lt;/span&gt; * &lt;span style="color: #6897bb"&gt;1024&lt;/span&gt; * &lt;span style="color: #6897bb"&gt;1024&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;// ** Specify an identity (any identity) in order to get it past .net3.5 sp1&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #ffc66d"&gt;EndpointIdentity&lt;/span&gt; epi = &lt;span style="color: #ffc66d"&gt;EndpointIdentity&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.CreateUpnIdentity(&lt;/span&gt;&lt;span style="color: #a5c25c"&gt;"unknown"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #ffc66d"&gt;EndpointAddress&lt;/span&gt; epa = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; &lt;span style="color: #ffc66d"&gt;EndpointAddress&lt;/span&gt;(&lt;span style="color: #cc7832"&gt;new&lt;/span&gt; &lt;span style="color: #ffc66d"&gt;Uri&lt;/span&gt;(address), epi);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; client = &lt;span style="color: #cc7832"&gt;new&lt;/span&gt; &lt;span style="color: #ffc66d"&gt;DocumentConverterServiceClient&lt;/span&gt;(binding, epa);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; client.Open();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;return&lt;/span&gt; client;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;catch&lt;/span&gt; (&lt;span style="color: #ffc66d"&gt;Exception&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CloseService(client);&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;throw&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; Check if the client is open and then close it.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray"&gt;///&lt;/span&gt;&lt;span style="color: green"&gt; &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;param name="client"&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;The client to close&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;public&lt;/span&gt; &lt;span style="color: #cc7832"&gt;static&lt;/span&gt; &lt;span style="color: #cc7832"&gt;void&lt;/span&gt; CloseService(&lt;span style="color: #ffc66d"&gt;DocumentConverterServiceClient&lt;/span&gt; client)&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #cc7832"&gt;if&lt;/span&gt; (client != &lt;span style="color: #cc7832"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; client.State == &lt;span style="color: #6897bb"&gt;CommunicationState&lt;/span&gt;&lt;span style="font-weight: normal"&gt;.Opened)&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; client.Close();&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Providing the project and all controls are named as per the steps above, it should compile without errors. Run it, enter the full path to the source file, e.g. an MS-Word document, and click the button to start the conversion process. The conversion may take a few second depending on the complexity of the document.&lt;/p&gt;
&lt;p&gt;Note that In this example we are programmatically configuring the WCF Bindings and End Points. If you wish you can use a declarative approach using the config file.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.muhimbi.com/Images---Files/Blog/Simple-PDF-Converter-Sample.aspx"&gt;Download the source code including a compiled binary.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Complex sample code&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In order to carry out internal testing we have developed an application that can be used to control each end every function exposed by the web services. The full source code as well as a compiled binary can be downloaded below.&lt;/p&gt;
&lt;p&gt;Note that although the test harness works well and can be used to batch convert a large number of documents, this is not commercial grade code. Use at your own risk.&lt;br&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Complex-Sample" border="0" alt="Complex-Sample" src="http://lh5.ggpht.com/_IgJp5HQ80aU/SxaZbl-AkbI/AAAAAAAAAI0/XBeZr_s7n0I/Complex-Sample%5B6%5D.jpg?imgmax=800" width="700" height="443"&gt; &lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.muhimbi.com/Images---Files/Blog/PDF-Converter-Test-Harness.aspx"&gt;Download the source code including a compiled binary&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Final notes&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;When using the PDF Converter from your own custom SharePoint code, you may want to consider using our &lt;a href="http://muhimbi.com/blog/2009/10/using-pdf-converter-for-sharepoint-from.html"&gt;high level Wrapper methods&lt;/a&gt;. If you are not using the wrapper methods then please make sure you are invoking the web service from a user who has privileges to do so. By wrapping the code in &lt;em&gt;SPSecurity.RunWithElevatedPrivileges&lt;/em&gt; you will automatically connect using an account in the WSS_WPG windows group, which has access by default.&lt;/p&gt;
&lt;p&gt;&lt;font color="white"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5787751540548761056-2966746172252397569?l=www.muhimbi.com%2Fblog%2Fdefault.html' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/2966746172252397569/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.muhimbi.com/blog/2009/12/converting-office-files-to-pdf-format.html#comment-form' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/2966746172252397569'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5787751540548761056/posts/default/2966746172252397569'/><link rel='alternate' type='text/html' href='http://www.muhimbi.com/blog/2009/12/converting-office-files-to-pdf-format.html' title='Converting Office files to PDF Format using a Web Services based interface'/><author><name>Muhimbi</name><uri>http://www.blogger.com/profile/09491299768917235399</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09047578615138636043'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>9</thr:total></entry></feed>