We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.Slides does not remove unnecessary embedded files


I found that Aspose.Slides (in contrast to Aspose.Words or Aspose.Cells) does not remove unnecessary embedded files in its zip-like file format.

I created a small app to demonstrate this:

// Create a simple presentation or open an existing one
using (var presentation = new Presentation())
	presentation.Save("clean.pptx", SaveFormat.Pptx);

// some random data for demonstration, but could be an executable file
var randomData = new byte[128];
new Random().NextBytes(randomData);

// Open pptx as zip and add random file which does not belong to the presentation itself
using var archive = new Archive("clean.pptx");
using var memoryStream = new MemoryStream(randomData);
	archive.CreateEntry("file.bin", memoryStream);

// Open presentation again and save it
using (var presentation = new Presentation("embedded_file.pptx"))
	//presentation.RemoveUnneededFiles() // pseudo code 
	presentation.Save("not_clean.pptx", SaveFormat.Pptx);

// file.bin is still present in the pptx file

So the data remain in the file after saving in Aspose.Slides (in Aspose.Words and Cells it gets removed). I want to prohibit our clients to introduce unwanted files.
When the presentation gets loaded somehow these additional files must be copied over to the dotnet object. So can I manually remove these files from the object somehow? Or is it simply a bug?

Unfortunately, when I add a file to a PPTX package and open it in PowerPoint, I get a message that the presentation has problems with the content (i.e. the document structure becomes incorrect). Could you share a presentation file with some embedded file that opens in PowerPoint without messages, please?

Hello Andrey

Thanks for your reply. Yes, Microsoft PowerPoint reports an error when the presentation with the embedded file is opened. The presentation can then be repaired by PowerPoint. The embedded file gets removed by this operation, this is the desired outcome.
On the other hand Aspose.Slides opens this presentation without problems and does not remove/repair the pptx. I would like to have a way to solve this with Aspose only (without PowerPoint)

You are right. I added a ticket with ID SLIDESNET-42769 in our tracking system. Our development team will consider a possibility for implementing this enhancement. You will be notified when this is implemented.