Wednesday 3 August 2011

PDF support in SharePoint 2010

PDF support in SharePoint 2010


SharePoint 2010 does not offer much support for PDF’s out of the box, but you can quickly get this in a few short steps.

Fist there is the missing icon issue. If you upload a PDF to a document library you just get this:

image

To add support for the PDF icon simply download it from here and place it in your Images directory on the each SharePoint server in your environment. (C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14TEMPLATEIMAGES)

Once you have the image in place update the DOCICON.xml file here: (C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14TEMPLATEXML) with the file type and image to use. (<Mapping Key="pdf" Value="pdficon_small.gif" />)

image

After the next IISReset you should have icons for your pdf files.

The second issue with PDF’s out of the box is searching for them. The Search service application does not have PDF as a file type to look for so you will need to add it. To accomplish this open central administration and click on “Manage Service Applications”. Now click “File Types” on the left menu pane.

image

Click “New File Type” and add PDF to the list.

image

Run a full crawl and you should now get PDF’s in your search results.

To enable the PDF iFilter see my previous post.



Silverlight SharePoint Web Part using the HTML Bridge

Silverlight SharePoint Web Part using the HTML Bridge


I recently ran across an issue with the HTML Bridge and conflicting behavior between IE and Firefox.

HTML Bridge info: http://msdn.microsoft.com/en-us/library/cc645076(v=VS.95).aspx

I had the following code in Silverlight to set a JavaScript variable to a Silverlight web part instance on a SharePoint page. By creating this variable I was able to call and pass in parameters into the Silverlight control from the JavaScript running on the page.






private static void InitializeReceiverJsVariable()
{
string pluginId = HtmlPage.Plugin.Id;if (string.IsNullOrEmpty(pluginId))
throw new Exception("No Silverlight Plugin found!  Ensure the Silverlight plugin has an ID!");

string jsCode = string.Format("var {0} = document.getElementById('{1}').content.{0};", JS_VARIABLE_NAME, pluginId);

HtmlPage.Window.Eval(jsCode);
}

Note: any Silverlight methods that you want call from JavaScript will need to have the [ScriptableMember] property on them. Alternatively you could create a class to house all your Scriptable methods and add the [ScriptableType] property to the whole class.

After compiling and deploying the web part to SharePoint, testing the JavaScript proved to be a success. Internet Explorer was allowing for communication between the Silverlight web part and the document library. Firefox was not allowing this. After several tests and some trial and error it turned out to be an issue with declaring the JavaScript variable from Silverlight. The solution was to declare the JavaScript variable on the page and just set the value from Silverlight instead of creating the variable too.

JavaScript addition:

var slWebPart = null;

Silverlight change:






private static void InitializeReceiverJsVariable()
{
string pluginId = HtmlPage.Plugin.Id;if (string.IsNullOrEmpty(pluginId))
throw new Exception("No Silverlight Plugin found!  Ensure the Silverlight plugin has an ID!");

string jsCode = string.Format("{0} = document.getElementById('{1}').content.{0};", JS_VARIABLE_NAME, pluginId);

HtmlPage.Window.Eval(jsCode);
}

After the change to the web part it worked in IE, Firefox, and Chrome. I still have not figured the exact issue or why you can’t declare the variable using the HTML Bridge, but the work around solved the problem. If you have come across this or know the technical reason, comments are always welcome.



Rectifying a missing namespace for MSBuild

Rectifying a missing namespace for MSBuild


Today I was working on adding some additional projects to a build and was getting the error:

Error CS0234: The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?)

Wait, what, this builds fine in visual studio…

System.Linq is part of System.Core. I did not have this directly referenced in visual studio but it built none the less.

image

I started to look at other projects in the build that used Linq but did not have any build issues and realized that they had System.Core referenced directly. So naturally I tried to go ahead and add System.Core to the project that was failing. Then I got this:

image

System.Core is automatically added by the build system. Well apparently not, so I had to add it manually. I opened the project file for my C# project in notepad and added the following to overwrite this error and get System.Core added.

image

After adding System.Core I was able to re-run the build and everything worked fine. As my co-worker Ralph would say, “it has been rectified”. hence the title of this blog post.

The cause of this issue is a project that is originally created as a .NET 4.0 project and then changed to a .NET 3.5 project. When Visual studio makes the alteration to the project file it does not handle adding System.Core into the project.


Find in files with preview pane



Find in files with preview pane

Fast Search Server iFilters for Tiffs and PDFs


Fast Search Server iFilters for Tiffs and PDFs




Setting up the Tiff iFilter on SharePoint Server 2010. Today I tried to apply this same approach to my 2010 FAST Search Server but hit a few bumps along the way. Several Bing searches lead me to someone talking about how both Tiff and PDF should work out of the box. I uploaded several document of both types, re-crawled and never got back any full text search results. I enabled the advanced filter pack, but still no luck. I did eventually get it working though and here is how I did it.

First I added the feature mentioned in the previous post for the Windows Tiff iFilter on the Fast Server.

image

Now that the feature is installed it will need to be registered. To register a iFilter for Fast server go to the formatdetector directory and edit the user_converter-rules.xml file.

image

I followed this article by Microsoft to register the tiff iFilter as a custom iFilter. I used this list by w3schools to get the mimetype reference needed to build my xml configuration.

image

After making your changes to the file make sure you keep a backup. If you ever install a FastSharePoint update or Service pack this file will be overwritten. This file is not backed up via the normal FastSharePoint backup procedures.

If you only care about Tiffs then you can run this power shell command (psctrl reset) on the Fast server and then re-crawl to get your full text search results.

image

To add PDF support download the latest PDF iFilter from adobe. Install the PDF iFilter on the Fast Server. Run the power shell command show above and then re-crawl all your content.

Now all PDF and Tiff documents should return full text search results.

image


Back up a service application (SharePoint Server 2010)


Back up a service application (SharePoint Server 2010)

We recommend that you regularly back up at the farm level. However, business or IT requirements might require that you back up a service application. Regularly backing up a service application reduces the possibility of data losses that might occur from hardware failures, power outages, or other problems. It is a simple process that helps to ensure that all the service application-related data and configurations are available for recovery, if that is required. You can back up one service application at a time, or you can back up all service applications at once. For information about what to back up and which tools to use, see Plan for backup and recovery (SharePoint Server 2010). For more information, see Back up a farm (SharePoint Server 2010).

Backing up a service application does not affect the state of the farm. However, it does require resources. Therefore, backing up a service application might affect farm performance while the backup is running. You can avoid performance issues by backing up the service application during hours when farm use is lowest.










note Note:
SharePoint Server 2010 backup backs up remote Binary Large Object (BLOB) stores but only if you are using the FILESTREAM remote BLOB store provider to put data in remote BLOB stores.If you are using another provider, you must manually back up the remote BLOB stores.

 


Procedures in this topic:











note Note:
You cannot use SQL Server tools or Data Protection Manager to back up a service application.

 


Task requirements




Before you begin, you must create a folder on the local computer or the network in which to store the backups. For better performance, we recommend that you back up to the local computer and then move the backup files to a network folder. For more information about how to create a backup folder, see Prepare to back up and recover (SharePoint Server 2010).










note Note:
Microsoft SharePoint Server 2010 backup backs up the Business Data Connectivity service external content type definitions but does not back up the data source itself. To protect the data, you should back up the data source when you back up the Business Data Connectivity service or the farm.If you back up the Business Data Connectivity service or the farm and then restore the data source to a different location, you must change the location information in the external content type definition. If you do not, the Business Data Connectivity service might not be able to locate the data source.

 



Use Windows PowerShell to back up a service application




You can use Windows PowerShell to back up one or more service applications manually or as part of a script that can be run at scheduled intervals.

To back up a service application by using Windows PowerShell




  1. Verify that you meet the following minimum requirements: See Add-SPShellAdmin.

  2. On the Start menu, click All Programs.

  3. Click Microsoft SharePoint 2010 Products.

  4. Click SharePoint 2010 Management Shell.

  5. At the Windows PowerShell command prompt, type the following command:Backup-SPFarm -Directory <BackupFolder> -BackupMethod {Full | Differential} -Item <ServiceApplicationName> [-Verbose]

    Where:

    • <BackupFolder> is the path of a folder on the local computer or on the network in which you want to store the backups.

    • <ServiceApplicationName> is the name of the service application that you want to back up.












    note Note:
    To back up all the service applications, at the Windows PowerShell command prompt, type the following command:Backup-SPFarm -Directory <BackupFolder> -BackupMethod {Full | Differential} -Item "FarmShared Service Applications" [-Verbose]

     












    note Note:
    If you are backing up the service application for the first time, you must use the Fulloption. You must perform a full backup before you can perform a differential backup.Some service applications always require a full backup. For these service applications, even if you select the Differential option, the system performs a full backup.

     



For more information, see Backup-SPFarm.










note Note:
We recommend that you use Windows PowerShell when performing command-line administrative tasks. The Stsadm command-line tool has been deprecated, but is included to support compatibility with previous product versions.

 




Use Central Administration to back up a service application




You can use Central Administration to back up a service application.

To back up a service application by using Central Administration




  1. Verify that the user account that performs this procedure is a member of the Farm Administrators group.

  2. In Central Administration, on the Home page, in the Backup and Restore section, click Perform a backup.

  3. On the Perform a Backup — Step 1 of 2: Select Component to Back Up page, select the service application from the list of components, and then click Next. To back up all the service applications, select the Shared Service Applicationsnode.










    note Note:
    The service application might consist of several components. You must select the top-level component.

     


  4. On the Start Backup — Step 2 of 2: Select Backup Options page, in the Backup Type section, select either Full or Differential.










    note Note:
    If you are backing up the service application for the first time, you must use the Fulloption. You must perform a full backup before you can perform a differential backup.Some service applications always require a full backup. For these service applications, the system performs a full backup even if you select the Differential option.

     


  5. In the Backup File Location section, in the Backup location box, type the path of the backup folder, and then click Start Backup.

  6. You can view the general status of all backup jobs at the top of the Backup and Restore Job Status page in the Readiness section. You can view the status for the current backup job in the lower part of the page in the Backup section. The status page updates every 30 seconds automatically. You can manually update the status details by clicking Refresh. Backup and recovery are Timer service jobs. Therefore, it may take several seconds for the backup to start.If you receive any errors, you can review them in the Failure Message column of the Backup and Restore Job Status page. You can also find more details in the Spbackup.log file at the UNC path that you specified in step 5.



SharePoint 2010 External Content types and SharePoint Designer 2010


SharePoint 2010 External Content types and SharePoint Designer 2010…




Recently I was testing External Content types to populate choices for a column in a document library. I used SharePoint designer 2010 to set up my external content type against a simple SQL database. Now that I had my external content type set up I saved it to SharePoint and had to go into central administration to assign the needed permissions. Once I had it all set up I then added an external data column to my library to use external content type while indexing my documents. So far, so good, or at least I thought. After getting everything set up and using the new column to index a few documents I decided to make a minor change to the external content type. I wanted to change the display name so it had a space in it. After making the change I then resaved the external content type, but my SharePoint column no longer worked.

AccessDenied

I was stumped, I was an administrator of everything in my environment but was denied access. All I did was change the display name. I tried to change the name back to what I had before but got the same error. After looking around for a bit I noticed that the version number of my External Content type had been updated with every save that I made in SharePoint Designer. I checked to see if any other settings had been changed and sure enough the permissions had all been reset.

permissions

I set my permissions once again and everything worked fine.

setpermission

So be careful when using SharePoint Designer 2010 as it will remove any permissions you have on an external content type when re-saving it to your site.


Setup the TIFF iFilter for SharePoint 2010


Setup the TIFF iFilter for SharePoint 2010




If your running SharePoint 2010 on Windows Server R2 or Windows 7 the Tiff iFilter is a great add on that will OCR all your scanned Tiff files. The feature is turned off by default due to the additional load it can put on processing, but its easy to enable and greatly benefits searching.

The first step to enable the iFilter is adding the feature to the server. This is done through Server Manger. Click on Features in the tree and then Add Features on the right.

image

Check the box next to Windows Tiff IFilter.

image

Click next to confirm your selection then install the feature.

Now the the feature is installed it needs to be enabled and configured. Click on the start button and type gpedit.msc into the search window to launch the local group policy editor.

image

Under Computer Configuration select Administration Templates, then select the OCR folder.

image

This is were you will configure OCR for Tiffs.

image

The first option is to force OCR for all pages in a tiff. The TIFF iFilter attempts to optimize performance by skipping blank pages or pages that have non-textual content such as pictures. In my scenario almost every tiff was an invoice so I enabled this to ensure that no pages were missed during the OCR process.

image

The next setting is for the OCR language that you wish to check for. By default this will be the server system language, however if you have several different languages that you are expecting you can enable them here as long as they are part of the same code page. For example you could check for English, Dutch, French, and Italian since they all belong to the Western European code page. If you wanted to look for Japanese and English though you would have to use some other means of OCR since the Tiff iFilter does not support using more than one code page. Since I was only using English Tiff I left this setting as “Not Configured”.

image

If you have already installed SharePoint prior to these steps you will need to restart the associated SharePoint services. I was using a stand alone development environment so I was able to just reboot my server.

Now that you have the Tiff iFilter installed a full crawl will need to be run to OCR the documents. To run a full crawl open up central administration and click on manage service application.

image

Click on Search Service Application.

image

Under crawling click content sources.

image

Start a full crawl.

image

Once the crawl has finished go to your document library and search for some text that should be in one of your tiffs to see if everything worked.

image

Results!

image

Getting full text search results from the OCR data collected by the Tiff iFilter is easy, free, and a greatly improves searching in SharePoint 2010.