Free Support Forum -

Looking for a library where i can automate pptx file with listed below things in C#

I’m looking for a library where i can automate the ppxt file in C#

  1. Open the pptx file from url/stream
  2. Replace the text
  3. Insert Images from url not from local folder
  4. Insert Videos from url not from local folder
  5. Create table structure to bind the data dynamically
  6. Save the edited file into Stream/byte array

Welcome to our community! Thank you for your request.

You can open a PPTX file from an URL or stream as below:

MemoryStream presentationStream;
using (var client = new System.Net.WebClient())
    var presentationData = client.DownloadData(pptxUrl);
    presentationStream = new MemoryStream(presentationData);

presentationStream.Seek(0, SeekOrigin.Begin);
var presentation = new Presentation(presentationStream);

More details: Manage Presentation

You can replace a slide text as below:

var shape = (AutoShape) presentation.Slides[0].Shapes[0];
shape.TextFrame.Text = "some text";

More details: Manage Text

You can insert images from an URL as below:

byte[] imageData;
using (var client = new System.Net.WebClient())
    imageData = client.DownloadData(imageUrl);

var image = presentation.Images.AddImage(imageData);

var slide = presentation.Slides[0];
var shape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 20, 20, 300, 200);
shape.FillFormat.FillType = FillType.Picture;
shape.FillFormat.PictureFillFormat.Picture.Image = image;

More details: PowerPoint Shapes

You can insert videos from an URL as below:

var slide = presentation.Slides[0];
var videoFrame = slide.Shapes.AddVideoFrame(10, 10, 320, 240, videoUrl);
videoFrame.PlayMode = VideoPlayModePreset.Auto;

//load a thumbnail
using (var client = new System.Net.WebClient())
    var thumbnailData = client.DownloadData(thumbnailUri);
    videoFrame.PictureFormat.Picture.Image = presentation.Images.AddImage(thumbnailData);

More details: Video Frame

You can save a presentation into Stream or byte array as below:

var memoryStream = new MemoryStream();
presentation.Save(memoryStream, SaveFormat.Pptx);

memoryStream.Seek(0, SeekOrigin.Begin);
var byteArray = new byte[memoryStream.Length];
memoryStream.Read(byteArray, 0, (int)memoryStream.Length);

More details: Save Presentation

Could you describe more details about your requirements for the table structures and data binding dynamically, please?