NullReferenceException during saving of Presentation

Hello.
I have this very simple piece of code:

const string file = @“2015+Training+Introduction2_source.pptx”;
var presentation = new Presentation(file);
foreach (var slide in presentation.Slides)
{
foreach (var textFrame in SlideUtil.GetAllTextBoxes(slide))
{
// textFrame.TextFrameFormat.AutofitType = TextAutofitType.None;

foreach (var paragraph in textFrame.Paragraphs)
{
paragraph.Text = paragraph.Text;
}
}
}

presentation.Save(“temp.pptx”, SaveFormat.Pptx);

The last line throws NullReferenceException with the following stack:
System.NullReferenceException: Object reference not set to an instance of an obj
ect.
at ↔?:slight_smile:.??:slight_smile:.§?:heart:(Paragraph[] paragraphs)
at ↔?:slight_smile:.??:slight_smile:…ctor(IParagraphFormat[] cumulativeStyle, ParagraphCollection para
graphs, Single width, Single height, Int32 columnCount, Single columnSpacing, Bo
olean wrapText, TextAnchorType anchor, Boolean anchorCenter, IBaseSlide slide, F
loatColor defaultColor, IFontsEffectiveData defaultFonts, FontCollectionIndex de
faultFontIndex, Single fontCoef, Single spacingReduction, ☼?:slight_smile: rc)
at Aspose.Slides.TextFrame.:slight_smile:?:heart:(Single width, Single height, IShapeStyle shape
Style, TextFrame[] parentFrames, ☼?:slight_smile: rc)
at Aspose.Slides.AutoShape.??:slight_smile:()
at Aspose.Slides.Shape.☼▲?()
at ???.?:slight_smile:?.???(Shape shape,? xfrm)
at ???.???.???(IShape shape, :spades:? spPrElementData, :bangbang:?? serializationContext)
at ???.§??.???(IAutoShape autoShape, ? shapeElementData, ?:slight_smile:? slideSerializati
onContext, ??? chartPartSerializationContext)
at ???.↔??.???(IGroupShape groupShape, ? groupShapeElementData, ?:slight_smile:? slideSeri
alizationContext, ??? chartPartSerializationContext)
at ???.↓??.???(IBaseSlide baseSlide, ?:arrow_up_down:? cSld, ?:slight_smile:? slideSerializationContext)

at ???.???.???(ISlide slide)
at ??.¶??.∟??(▲:diamonds:? package, ISlide slide, :bangbang:?? serializationContext)
at ??.¶??.☼??(IPresentation presentation, ↔?:slight_smile: zipFile, ??:slight_smile: outputType, IPptxO
ptions options)
at Aspose.Slides.Presentation.Write(Stream stream, ??:slight_smile: type, IPptxOptions opt
ions)
at Aspose.Slides.Presentation.Save(Stream stream, SaveFormat format, ISaveOpt
ions options)
at Aspose.Slides.Presentation.Save(String fname, SaveFormat format)

This error occures only when processing one specific document (see attachments). Other documents I’ve tried do not seem to cause this issue.

I’ve found a workaround for this issue: if you uncomment a line where TextFrameFormat.AutofitType is set to None, Presentation.Save will not throw.

Could you please have a look at this problem and solve it?

I’m using Aspose slides 14.6.0.0 for .NET

P.S. Further investigation shows that slide 39 causes a problem. You can do this:
foreach (var slide in presentation.Slides.Skip(38).Take(1))
and still cause a NRE. Other slides in this document do not seem to cause NRE.

Hi Artem,

Thanks for your interest in Aspose.Slides.

I have worked with the presentation file shared by you and have tried sample code shared by you using Aspose.Slides for .NET 14.8.1 on my end. I have encountered no issue on my end. Can you please try using the specified version on your end and share with us if there is still an issue.

Many Thanks,