- Code: Select all
new_ppt = Presentation()
new_ppt.Slides.RemoveAt(0) # Remove default blank slide
try:
# Add slide copy to new presentation
new_slide = new_ppt.Slides.AppendBySlide(ppt.Slides[i])
# Save to file
output_file = os.path.join(outputFolder, f"Slide_{i+1}.pptx")
new_ppt.SaveToFile(output_file,FileFormat.Auto)
finally:
# Ensure resources are cleaned up
new_ppt.Dispose()
Here is the wrong message:
raise SpireException(info)
spire.presentation.common.SpireException: TypeInitialization_Type_NoTypeAvailable: at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0xbd
at System.Runtime.CompilerServices.ClassConstructorRunner.CheckStaticClassConstructionReturnNonGCStaticBase(StaticClassConstructionContext*, IntPtr) + 0xd
at sprbfg..ctor(Int32, Int32, Single, Single, SKColorType) + 0x65
at sprfh5..ctor(sprbfk) + 0xc7
at sprdfa..ctor(Int32, Int32, Single, Single, Boolean) + 0x7c
at sprciu..ctor(TextParagraphProperties[], ParagraphCollection, Single, Single, Int32, Single, Boolean, TextAnchorType, Boolean, ActiveSlide, ColorFormat.a, LocaleFonts, FontCollectionIndex, Single, Single, Int32, Object, sprcjg) + 0xcf
at sprcjq.spra(Single, Single, ShapeStyle, sprcjq[], sprcjg) + 0xfa5
at sprci1.PptxPrepareForSaving(sprc53) + 0x1ae
at Spire.Presentation.Collections.ShapeList.spra(sprc53) + 0x7d
at Spire.Presentation.GroupShape.PptxPrepareForSaving(sprc53) + 0x180
at Spire.Presentation.ActiveSlide.PresentationBeforeSave(sprc53) + 0x81
at sprci8.PresentationBeforeSave(sprc53) + 0x5d
at sprcjd.spra(sprc53, sprchz) + 0x7e2
at sprcjd.spra(Stream, sprchz, sprdfb) + 0xa5
at sprcjd.spra(Stream, sprde6, sprde7) + 0xa5
at Spire.Presentation.Presentation.SaveToFile(Stream, FileFormat) + 0x24e
at Spire.Presentation.AOT.NLPresentation.Presentation_SaveToFileFF(IntPtr, IntPtr, Int32, IntPtr) + 0x5a0