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

Free Support Forum - aspose.com

Could Not Get Text from Password Protected PPTX File

Whenever i am trying get text from password protected .pptx file at that time it throws an exception from below code in Aspose.Slides C#.

string filePath=@"S:\2022\Input Data\This is password protected file.pptx";

IPresentationText presentationText= PresentationFactory.Instance.GetPresentationText(filePath,TextExtractionArrangingMode.Unarranged);

It gives below error:
'Object reference not set to an instance of an object.'.. Aspose.Slides.PptUnsupportedFormatException: 'Unknown file format.'.

Please provide solution for this issue.

Thank you for contacting support.

You should specify a valid password to read content from a password-protected presentation as shown below:

var loadOptions = new LoadOptions
    Password = "my_password"

using (var fileStream = File.OpenRead(filePath))
    var presentationText = PresentationFactory.Instance.GetPresentationText(
        fileStream, TextExtractionArrangingMode.Unarranged, loadOptions);

    // ...

But I found some issues when using this way. Therefore, I’ve added a ticket with ID SLIDESNET-43323 to our issue tracking system. We apologize for any inconvenience. Our development team will investigate the case. You will be notified when the issue is resolved.

As a temporary workaround, you can load password-protected presentations as shown in this article: