How to Apply or Remove Protection on PPTX Shapes inside .NET Applications
This technical tip explains how .NET developers can apply and remove protection to presentation. A common use for Aspose.Slides is to create, update and save Microsoft PowerPoint 2007 (PPTX) presentations as part of an automated workflow. Users of the application that uses Aspose.Slides this way get access to the output presentations. Protecting them from editing is a common concern. It is important that auto-generated presentations retain their original formatting and content. A common use for Aspose.Slides is to create, update and save Microsoft PowerPoint 2007 (PPTX) presentations as part of an automated workflow.
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
//your code here...// Applying Protection to PPTX Shapes
//[C# Code Sample]
//Instatiate Presentation class that represents a PPTX file
Presentation pTemplate = new Presentation(path + "RectPicFrame.pptx");//Instatiate Presentation class that represents a PPTX file
Presentation pTemplate = new Presentation("RectPicFrame.pptx");
//ISlide object for accessing the slides in the presentation
ISlide slide = pTemplate.Slides[0];
//IShape object for holding temporary shapes
IShape shape;
//Traversing through all the slides in the presentation
for (int slideCount = 0; slideCount < pTemplate.Slides.Count; slideCount++)
{
slide = pTemplate.Slides[slideCount];
//Travesing through all the shapes in the slides
for (int count = 0; count < slide.Shapes.Count; count++)
{
shape = slide.Shapes[count];
//if shape is autoshape
if (shape is IAutoShape)
{
//Type casting to Auto shape and getting auto shape lock
IAutoShape Ashp = shape as IAutoShape;
IAutoShapeLock AutoShapeLock = Ashp.ShapeLock;
//Applying shapes locks
AutoShapeLock.PositionLocked = true;
AutoShapeLock.SelectLocked = true;
AutoShapeLock.SizeLocked = true;
}
//if shape is group shape
else if (shape is IGroupShape)
{
//Type casting to group shape and getting group shape lock
IGroupShape Group = shape as IGroupShape;
IGroupShapeLock groupShapeLock = Group.ShapeLock;
//Applying shapes locks
groupShapeLock.GroupingLocked = true;
groupShapeLock.PositionLocked = true;
X
Url: http://www.aspose.com/.net/powerpoint-component.aspx
Language: C# | User: Sheraz Khan | Created: Sep 9, 2015 | Tags: Apply Protection to PPTX Shapes, Removing Protection from presentation, Saving the presentation file, get access to the output presentations,, .NET PowerPoint API, PowerPoint .NET Component Apply Protection to PPTX Shapes Removing Protection from presentation Saving the presentation file get access to the output presentations .NET PowerPoint API PowerPoint .NET Component