The all-new PowerPoint Automation Services has brought to SharePoint 2013 for PowerPoint presentations, on-premises, what Word Automation Services brought to Word documents for SharePoint in 2010: the ability to convert documents, at server scale, into other formats.
For Word Automation Services, everything for SharePoint 2010 remains in play for SharePoint 2013. However, the biggest addition is that the architecture for Word Automation Services was reworked to allow for synchronous and asynchronous, on-demand, streamed file conversion to augment the traditional timer job conversions. SharePoint 2010 and 2013 enable you to create a document conversion job that runs on the timed interval of Word Automation Service, which works well to support batch processing of documents. SharePoint administrators can set the time interval for running Word Automation Services to be as often as every one minute, but sometimes that isn’t soon enough. With the redesigned architecture, conversion requests can be submitted and processed in real-time. On demand, streamed requests can be made for one file at a time, and whether synchronously or asynchronously requested, the queue manager/scheduler in the new architecture processes the on-demand request as its highest priority.
PowerPoint Automation Services is the newcomer, so you’ll take a look at it a little more deeply. Organizations often have thousands of PowerPoint presentations that are in various file formats ranging from the PowerPoint 97–2003 binary formats known as .ppt to the newer file formats based on Open XML known as .pptx. Additionally, sometimes you do not want to provide a presentation in its native format to others so you need to convert it to a fixed format such as .pdf or images such as .jpg or .png. This often is the case for presentations that are used at conferences where you want attendees to receive a .pdf version. For business cases like these PowerPoint Automation Services can now provide the server-side performance and scale to move these file conversions out of being an antiquated, laborious, manual process.
Unlike Word Automation Services though, no timer job option exists for PowerPoint Automation Services. Files are streamed, which you can do in a synchronous or asynchronous pattern. Also, the solutions you build for PowerPoint Automation Services will be farm-level solutions; the APIs are only available on the SharePoint server.
You can develop your solution using the Microsoft.Office.Server.PowerPoint.Conversion namespace. Using the namespace you have the classes you need for the types of conversions available. Using the PresentationRequest class you can input the binary .ppt file and output a new .pptx file. For fixed format file conversion, the PdfRequest and XpsRequest classes are used to input either a .ppt or .pptx file and output a .pdf or .xps file, respectively. The PictureRequest class can also take as input a .ppt or .pptx file and output either a .jpg or .png depending on your preference. For exposure to the coding involved, the following Try It Out shows you how to build a small console application to exercise PowerPoint Automation Services.
using System.IO; using System.Web; using Microsoft.SharePoint; using Microsoft.Office.Server.PowerPoint.Conversion;
try { string mySiteURL = "http://YourServerNameHere/YourSiteHere"; using (SPSite mySite = new SPSite(mySiteURL)) { using (SPWeb myWeb = mySite.OpenWeb()) { Console.WriteLine("Convert to .pdf Start"); // Identify document library and input file SPFolder myDocs = myWeb.Folders[mySiteURL + "/YourDocumentLibrary"]; SPFile myFile = myDocs.Files[mySiteURL + "/YourDocumentLibrary/YourPresentationName.pptx"]; // Create a stream object for the file Stream myFileStream = myFile.OpenBinaryStream(); SPFileStream myStream = new SPFileStream(myWeb, 0x1000); // Rrequest conversion to .pdf format. PdfRequest myRequest = new PdfRequest( myFileStream, ".pptx", myStream); // Rrequest is sent synchronously, when // 'null' value is used for the callback parameter. // Response is in the result object. IAsyncResult result = myRequest.BeginConvert( SPServiceContext.GetContext(mySite), null, null); // Use the EndConvert method to get the result. myRequest.EndConvert(result); // Add the converted file to the document library. SPFile myNewPdfFile = myDocs.Files.Add( "newConvertedPresentation.pdf", myStream, true); Console.WriteLine("New file name: {0}", myNewPdfFile.Url); } } } catch (Exception ex) { Console.WriteLine("Error Message: " + ex.Message); } finally { Console.WriteLine("Conversion to .pdf completed. Press <Enter> to quit."); Console.ReadLine(); }
PowerPoint Automation Services makes a nice addition to the Office server-side services. In this Try It Out you used a console application to make your conversion request, but in a production enterprise environment, you can drive your conversion requests to PowerPoint Automation Services off a variety of SharePoint interactions, whether it’s an end user clicking a button on a web part, an event firing on a list item, or a workflow action calling out to a service endpoint that has access to the SharePoint server. Solutions can also include the use of other technologies such as the Open XML SDK, where you can dynamically augment or generate entire presentations by incorporating data from external data sources, charts or tables from Excel, content from Word, or other PowerPoint presentations for that matter. As with Word Automation Services, PowerPoint Automation Services now joins the ranks for shifting the often manual workload for presentation conversion to other formats into an automated conversion processes on the SharePoint server.