Powerpoint Automation Services in SharePoint

sharePoint


Many of organization small or large, uses Microsoft SharePoint Server as a repository for document and  PowerPoint presentations. These businesses all have their particular needs for distributing , updating, and storing their presentations. Microsoft PowerPoint Automation Services is a new feature of Microsoft SharePoint Server 2013 that can help enterprises or business to manage their presentations.

It is a shared service that provides server-side conversion of PowerPoint presentations into other formats like pptx, ppt,  xps, jpg etc. It was designed from the outset to work on servers and can process many presentation files in a reliable and predictable manner.

Using PowerPoint Automation Services, you can convert from the PowerPoint binary file format (.ppt) and the PowerPoint Open XML file format (.pptx) to other formats. For example, you may want to upgrade a batch of PowerPoint 97–2003 files to Open XML presentation files.

All of these classes related to this are contained in Microsoft.Office.Server.PowerPoint.Conversion namespace.

To Create the application


1. Start the Microsoft Visual Studio 2012.

2. Create New Project dialog box, under Installed, expand Templates, expand Visual C#, and then chose Windows.

  •   Add a reference to System.Web and Microsoft.SharePoint.

  •  Also in the Add Reference of Microsoft.Office.Server.PowerPoint.dll (default location is :\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.Office.Server.PowerPoint\v4.0_15.0.0.0__71e9bce111e9429c).


[csharp]

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using Microsoft.SharePoint;
using Microsoft.Office.Server.PowerPoint.Conversion;

namespace PPSExample
{
class Program
{
static void Main(string[] args)
{
try
{
string siteUrl = "http://<server name>";
using (SPSite site = new SPSite(siteUrl))
{
using (SPWeb web = site.OpenWeb())
{



SPFolder docs = web.GetFolder(siteUrl+ "/Shared Documents"];
SPFile file = docs.Files[siteURL +Shared Documents/file1.ppt"];

// Convert the file to a stream and
Stream fileStream = file.OpenBinaryStream();
SPFileStream spFileStream = new SPFileStream(web, 0x1000);

// Create the presentation conversion request.
PresentationRequest request = new PresentationRequest(fileStream,
".ppt",
spFileStream);

// Send the request synchronousl

IAsyncResult result = request.BeginConvert(
SPServiceContext.GetContext(site),
null,
null);

request.EndConvert(result);

SPFile newFile = docs.Files.Add(
"newFile1.pptx",
stream,
true);
Console.WriteLine(newFile.Url);

}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
Console.WriteLine("Completed");
Console.ReadKey();
}
}
}
}

[/csharp]

To Run this example


Before running this example make sure that the PowerPoint Conversion Service Application and PowerPoint Conversion Service Application Proxy are set to Started in central admin.

1. Upload a ppt named file1.ppt to the Shared Documents library in the SharePoint site.

2.  Build and run the example.

3. After waiting one minute for the conversion process to run, navigate to the Shared Documents library. The document library now contains a new PowerPoint document, newFile1.pptx.
Share on Google Plus

About JK STACK

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.

5 comments:

  1. Hy Sir;

    i've tried to execute this code in 3 different sharepoint 2013 Vm, without success, my error was always: the specified document cannot be converted.

    Have you a separate domain controller? or have you test this code on a developper VM with a domain controller included in the same Vm

    thank's

    ReplyDelete
  2. Hi,

    Just check as a per-requiste you have also started power point service from central admin.

    Let us know if you are still facing the issue again, please share the appropriate logs from 15 hive folder.

    ReplyDelete
  3. Yes they are on(service from central admin),.but nothing works

    is tout DC separate from SharePoint machine ?

    ReplyDelete
  4. is your DC separate from SharePoint machine ?

    ReplyDelete
  5. This will definitely be very useful for me when online bass tuner I get a chance to start my blog. Sharing-and-Visibility-Designer exam questions

    ReplyDelete