Monday, May 2, 2011
Sunday, May 1, 2011
Blog Post: Using SharePoint 2010 Word Automation Services to convert Word documents to PDF files
A very interesting feature of SharePoint 2010 is the Word automation services. Word automation services allows you to convert between multiple document formats which runs as a batch job. This is very useful in many server side scenarios where customers require to archive documents, protect them from editing among many others.
I am Sharing the following code snippets that will allow you to convert between multiple document formats....
private void ConvertDocFileToPDF(SPFile filex)
{
// The job and its settings
ConversionJobSettings settings;
ConversionJob job;
// Set the conversion settings, the enumeration allows you to convert to PDF, RTF, XPS and other word formats
settings = new ConversionJobSettings();
settings.OutputFormat = SaveFormat.PDF;
// Create th conversion job...this must be the name of the job as defined in SharePoint farm
job = new ConversionJob(ConfigurationHelper.Instance.DocumentConversionService, settings);
// Most propably, you will want this job to run with system credintials, however, you can use other
job.UserToken = SPUserToken.SystemAccount;
// Add your file to the conversion job...in this example, you can also save the converted file to an attachement!!! IN the below code, you might use the SPContext object to get the root URL of your website
string pdfFile = filex.Url.Replace("docx","pdf")
job.AddFile("http://<your site URL>/"+ filex.Url, "http://<your site URL>/" + pdfFile);
// Start the conversion job
job.Start();
}
You will need to add reference to the assembly "Microsoft.Office.Word.Server" which you will find in "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\".
To ensure that your code runs with no problem, ensure that you did setup a Word Automation Service in your SharePoint farm by checking the service applications from the central administration, or create new one...
when you want to test it, run the job "Word Automation Services Timer Job" which will allow you to test the conversion immediately. If you cannot find this job, this means that the configuration is missed up and your code will probably not run, so check this job first before running your code.
Happy coding:)
Beyoncé Nelly Furtado Leeann Tweeden Bali Rodriguez Izabella Miko
Could ?Cloud? Become a Dirty Word for Consumers?
Karen Carreno Bijou Phillips Marika Dominczyk Dita Von Teese Rachel Nichols
Blog Post: Getting "The search request was unable to connect to the search service"
After crawling successfully and validating that documents were indexed by FAST, you were still unable to search from SharePoint, and receive this error:
The search request was unable to connect to the search service
In ULS we are getting
03-28-2011 11:25:05.71 w3wp.exe (0x0B90) 0x1D08 SharePoint Server Search Query g4hx Monitorable FASTSearchRuntime::SendRequest--Search Service Not Found Exception when trying to search FAST backend: Microsoft.Office.Server.Search.Query.SearchServiceNotFoundException: The search request was unable to connect to the Search Service. ---> System.ServiceModel.FaultException`1[Microsoft.Office.Server.Search.Administration.SearchServiceApplicationFault]: The creator of this fault did not specify a Reason. (Fault Detail is equal to Microsoft.Office.Server.Search.Administration.SearchServiceApplicationFault). --- End of inner exception stack trace --- at Microsoft.Office.Server.Search.Administration.SearchServiceApplicationProxy.ThrowBackwardCompatibleException(FaultException`1 ex) at
Cause:
The processes responsible for Claims-based authorization in FAST were not able to initialize successfully, with the following seen in the authorization-admin log:
AdminLibrary.dll:MakeRemoteRequestToWorker - Unable to complete request to sam worker node
AdminLibrary.dll:Resuscitate - Unable to get LastCommittedTransactionId
Resolution:
These communication errors were causing by a missing SPN either for the user or the machine name, which we correct with setspn on the domain controller:
setspn -A HTTP/fastmachine DOMAIN\fastuser
setspn -A HTTP/fastmachine.domain.extension DOMAIN\fastuser
Laura Prepon Ashley Scott Michelle Behennah Julie Benz Saira Mohan
How Social Commerce Really Works & Why
Molly Sims Monika Kramlik Lacey Chabert Amber Brkich Gretha Cavazzoni