Hi Sumeet,
Refer below sample.
Install Spire.Presentation library
Use the following command.
Install-Package Spire.Presentation
HTML
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" EmptyDataText="No files uploaded">
<Columns>
<asp:BoundField DataField="Text" HeaderText="File Name" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkPreview" Text="Preview" CommandArgument='<%# Eval("Value") %>'
runat="server" OnClick="Preview"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<hr />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<script type="text/javascript">
$(function () {
$('.carousel').carousel({
interval: 1000
});
$('.item')[0].className = "item active";
});
</script>
<div id="myCarousel" class="carousel slide" align="center" data-ride="carousel" data-pause="hover">
<div class="carousel-inner" align="center" role="listbox">
<asp:Repeater ID="rptImages" runat="server">
<ItemTemplate>
<div class="item">
<div class="carousel-content">
<asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("Data") %>' />
</div>
</div>
</ItemTemplate>
</asp:Repeater>
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
Namespaces
C#
using System.IO;
using Spire.Presentation;
VB.Net
Imports System.IO
Imports Spire.Presentation
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
string[] filePaths = Directory.GetFiles(Server.MapPath("~/Files/"));
List<ListItem> files = new List<ListItem>();
foreach (string filePath in filePaths)
{
files.Add(new ListItem(Path.GetFileName(filePath), filePath));
}
GridView1.DataSource = files;
GridView1.DataBind();
}
}
protected void Preview(object sender, EventArgs e)
{
string filePath = (sender as LinkButton).CommandArgument;
this.CreateSlideShow(filePath);
}
private void CreateSlideShow(string filePath)
{
//Create a Presentation instance.
using (Presentation presentation = new Presentation())
{
//Load a PowerPoint document.
presentation.LoadFromFile(filePath);
List<SlideData> slideImages = new List<SlideData>();
//Iterate through all slides in the PowerPoint document.
foreach (ISlide slide in presentation.Slides)
{
//Save each slide as PNG image.
System.Drawing.Image image = slide.SaveAsImage();
byte[] bytes = (byte[])(new System.Drawing.ImageConverter()).ConvertTo(image, typeof(byte[]));
slideImages.Add(new SlideData { Data = "data:image/jpg;base64," + Convert.ToBase64String(bytes) });
}
rptImages.DataSource = slideImages;
rptImages.DataBind();
}
}
public class SlideData
{
public string Data { get; set; }
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim filePaths As String() = Directory.GetFiles(Server.MapPath("~/Files/"))
Dim files As List(Of ListItem) = New List(Of ListItem)()
For Each filePath As String In filePaths
files.Add(New ListItem(Path.GetFileName(filePath), filePath))
Next
GridView1.DataSource = files
GridView1.DataBind()
End If
End Sub
Protected Sub Preview(ByVal sender As Object, ByVal e As EventArgs)
Dim filePath As String = (TryCast(sender, LinkButton)).CommandArgument
Me.CreateSlideShow(filePath)
End Sub
Private Sub CreateSlideShow(ByVal filePath As String)
'Create a Presentation instance.
Using presentation As Presentation = New Presentation()
'Load a PowerPoint document.
presentation.LoadFromFile(filePath)
Dim slideImages As List(Of SlideData) = New List(Of SlideData)()
'Iterate through all slides in the PowerPoint document.
For Each slide As ISlide In presentation.Slides
'Save each slide as PNG image.
Dim image As System.Drawing.Image = slide.SaveAsImage()
Dim bytes As Byte() = CType((New System.Drawing.ImageConverter()).ConvertTo(image, GetType(Byte())), Byte())
slideImages.Add(New SlideData With {
.Data = "data:image/jpg;base64," & Convert.ToBase64String(bytes)
})
Next
rptImages.DataSource = slideImages
rptImages.DataBind()
End Using
End Sub
Public Class SlideData
Public Property Data As String
End Class
Screenshot