Microsoft Server Faimly & More ....., SharePoint 2010 Products & Technologies, SharePoint User Group

New York City SharePoint Developers UG Post Session Resources

Last Wednesday I delivered a session on “SharePoint 2010 Branding & Customization for Public Facing Sites” at NYC SharePoint Developers User Group at MSFT. As promised following are the links to the session content and related downloads.

Presentation: Watch Online | Download (pptx, ppt, pdf ,xps)

Demo: Master Page + Page Layout + HTML Layout (CSS + Images) | Watch Online | Download Video

Take a look at quick walk through on how to run a demo (for high definition video download it from link above). Make sure you have anonymous user enabled on your web application and site collection otherwise last part where I logged in as anonymous user will not work.

PS: I tried to use Camtasia to record the complete session but it turns out to be a pain as it seems to get stuck for updates and once finally start recording it has some issues with audio (doesn’t sync properly), if I manage to get it working I will upload it as well.

SharePoint 2010 Products & Technologies

Programmatically saving SharePoint Server 2010 barcode Images and values to a File System

While working with Barcodes in SharePoint Server 2010, customer wants to utilize them bit more than just use them as part of list item. Initially they are looking for barcodes (from some 3rd parties) to do the job but when implemented via SharePoint using OTB barcodes policy it was nearly a perfect solution for them, except that they also want the barcodes to be saved (in form of a image) along with barcode number/value (which is essentially also acts as a file name) on a file system. Also they want this to be done externally from SharePoint Interface (although still on the server side) more of like a batch or console app. As it turns out it’s more straightforward than I initially thought it would be, as following code reveals. Basically end result was a console app which runs on demand and gets all the barcode from the specific list and simply save the barcode as image (jpg in this case but it can be in other formats) and give it same name as barcode number/value. Following fragment is actually the core of it.

SaveBarcodes(SPWeb web, string listName, System.Drawing.Imaging.ImageFormat imgFormat)


SPList list = web.Lists.TryGetList(listName);

SPQuery query = new SPQuery();

Image img;

     //Just read the fields we need for this task

query.ViewFields = string.Concat(

“<FieldRef Name=’_dlc_BarcodePreview’ />”, “<FieldRef Name=’_dlc_BarcodeImage’ />”, “<FieldRef Name=’_dlc_BarcodeValue’ />”);

query.ViewFieldsOnly = true;

SPListItemCollection listCol = list.GetItems(query);

foreach (SPListItem item in listCol)


img = Barcode.GetBarcodeImage(item);

 img.Save(string.Format(“{0}.{1}”, Barcode.GetBarcodeValue(item), imgFormat.ToString()), imgFormat);



Please note that you have to add references to “Microsoft.Office.Policy” and “System.Drawing” assemblies to compile the code. Also add namespaces “Microsoft.Office.RecordsManagement.PolicyFeatures” and “System.Drawing.Image” as they will be required.

Following is the final outcome, see the barcodes saved as images and name of the files are same as that of barcode number/value.