Skip to content

Commit 7034cbb

Browse files
Merge pull request #94 from VijayadharshiniMathiyalagan/ES-882954-How-to-editing-the-alt-text-in-image
Add sample for edit text and alt text of image
2 parents 3170721 + 8b72a4c commit 7034cbb

File tree

5 files changed

+69
-0
lines changed

5 files changed

+69
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35417.141 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Edit-text-and-image-alt-text", "Edit-text-and-image-alt-text\Edit-text-and-image-alt-text.csproj", "{E1319FAA-3500-4DAE-A3C6-35FFB542911F}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{E1319FAA-3500-4DAE-A3C6-35FFB542911F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{E1319FAA-3500-4DAE-A3C6-35FFB542911F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{E1319FAA-3500-4DAE-A3C6-35FFB542911F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{E1319FAA-3500-4DAE-A3C6-35FFB542911F}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Edit_text_and_image_alt_text</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.Presentation.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<None Update="Data\Template.pptx">
17+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
18+
</None>
19+
<None Update="Output\.gitkeep">
20+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
21+
</None>
22+
</ItemGroup>
23+
24+
</Project>

Slides/Edit-text-and-image-alt-text/Edit-text-and-image-alt-text/Output/.gitkeep

Whitespace-only changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Syncfusion.Presentation;
2+
3+
//Load or open an PowerPoint Presentation.
4+
using FileStream inputStream = new(Path.GetFullPath(@"Data/Template.pptx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
5+
//Open an existing PowerPoint presentation.
6+
using IPresentation pptxDoc = Presentation.Open(inputStream);
7+
//Retrieve the slide instance.
8+
ISlide slide = pptxDoc.Slides[0];
9+
//Retrieves the first shape.
10+
IShape shape = slide.Shapes[0] as IShape;
11+
//Retrieves the first paragraph of the shape.
12+
IParagraph paragraph = shape.TextBody.Paragraphs[0];
13+
//Retrieves the first TextPart of the shape.
14+
ITextPart textPart = paragraph.TextParts[0];
15+
//Modifies the text content of the TextPart.
16+
textPart.Text = "Hello Presentation";
17+
//Retrieve the first picture from the slide.
18+
IPicture picture = slide.Pictures[0];
19+
//Modifies the label of the image.
20+
picture.Description = "Replaced alt text";
21+
//Saves the modified PowerPoint Presentation.
22+
using FileStream outputStream = new(Path.GetFullPath(@"Output/Result.pptx"), FileMode.Create, FileAccess.ReadWrite);
23+
pptxDoc.Save(outputStream);

0 commit comments

Comments
 (0)