Saturday, 15 February 2014

Powerpoint Automation Services in 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.Conversionnamespace.

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 choseWindows.
  •   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).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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();
}
}
}
}

To Run this example

Before running this example make sure that the PowerPoint Conversion Service Application andPowerPoint 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.

No comments:

Post a Comment