Aspose.Slides for C++: paragraph->GetRect() Throws a NullReferenceException

@pankajku,

With Aspose.Slides for 25.6, I used the following code example:

auto filePathTemplate = u"slide_{0}_shape_{1}_{2}.png"; // the third parameter is the shape name

auto presentation = MakeObject<Presentation>(u"Test1.pptx"); // and test1 (1) 2 copy.pptx, thumbnailPPT.pptx

try {
    auto slideCount = presentation->get_Slides()->get_Count();

    for (int slideIndex = 0; slideIndex < slideCount; slideIndex++) {
        auto slide = presentation->get_Slide(slideIndex);
        auto shapeCount = slide->get_Shapes()->get_Count();

        for (int shapeIndex = 0; shapeIndex < shapeCount; shapeIndex++) {
            auto shape = slide->get_Shape(shapeIndex);

            if (ObjectExt::Is<IAutoShape>(shape)) {
                auto autoShape = ExplicitCast<IAutoShape>(shape);

                auto shapeImage = autoShape->GetImage();
                auto shapeName = autoShape->get_Name();

                auto filePath = String::Format(filePathTemplate, slideIndex, shapeIndex, shapeName);
                shapeImage->Save(filePath, ImageFormat::Png);
                shapeImage->Dispose();
            }
        }
    }
}
catch (const Exception& e) {
    Console::WriteLine(e->get_Message());
}

presentation->Dispose();

The output images for the “Test1.pptx” file: Test1.pptx.output.zip (306.4 KB)
The output images for the “test1 (1) 2 copy.pptx” file: test1 (1) 2 copy.pptx.output.zip (9.5 KB)
The output images for the “thumbnailPPT.pptx” file: thumbnailPPT.pptx.output.zip (2.5 KB)

Used the exact same code snippet that you provided on thumbnail.pptx
Still getting the same exception error: System::NullReferenceException: Object reference not set to an instance of an object.

@pankajku,
Unfortunately, I was still unable to reproduce the error you described. Please try to isolate the problem and share more details on how to do this.

Please share which details would be helpful to reproduce error at your end.
For me with the code snippet you have provided, and file thumbnail.pptx containing single shape is showing the error.

@pankajku,
Unfortunately, I don’t know what could be the cause of the error and what information can help us reproduce it. You should try to isolate it. First, you can run the code on a clean operating system.