How to Specify a Reading Order of Objects in PowerPoint Presentations in C#?

PowerPoint has a reading order pane that essentially changes the Tab Order (or screen reader order) of the shapes on the slides.

image.png (27.7 KB)

Note that the reading order is different from shapes’ order in the Selection Pane which is by their ZOrderPosition.

Is there a way to specify reading order in Aspose.Slides?

@bingxie,
Thank you for contacting support. I am working on the question you posted and will get back to you soon.

@bingxie,
I have not found features to manage the reading order of objects on slides using Aspose.Slides and added a ticket with ID SLIDESNET-43697 to our issue-tracking system. Our development team will consider implementing such features. You will be notified when a new release of Aspose.Slides with an update is published.

Thanks for looking into this @Andrey_Potapov

I spent some time researching this issue today. Here are my observations:

  1. It seems that Reading Order is simply the reverse order of the shapes in the Selection Pane. Reordering the items in the Reading Order pane changes the ZOrder position.

  2. Deselecting the checkbox in the Reading Order pane simply marks that Shape as Decorative. This feature is not currently supported as previously reported under SLIDESNET-43525.

@bingxie,
Thank you for your observations. I’ve forwarded them to our developers.

@bingxie,
Our developers have reviewed your requirements.

  1. The screen reader reads the elements on a slide in the order they were added (see here). Therefore, the order of shapes in the slide’s IShapeCollection corresponds to the Reading order in PowerPoint.
    To get a shape’s position in the reading order, use the IShape.ZOrderPosition property.
    To determine the shape’s ordinal number as shown in the Reading Order pane, you can use the following code:
public static int GetShapeReadingOrderNumber(IShape shape, IShapeCollection shapes)
{
    if (shape.IsDecorative)
        return -1; // Shapes marked as decorative do not participate in the reading process.

    int readingOrderNumber = 1;
    foreach (var sh in shapes)
    {
        if (sh.IsDecorative)
            continue;

        if (sh.OfficeInteropShapeId == shape.OfficeInteropShapeId)
            return readingOrderNumber;

        readingOrderNumber++;
    }
    return -1; // This shape is not found in the collection.
}
  1. To deselect a shape on the Reading Order pane you can use the IShape.IsDecorative property:
using (Presentation presentation = new Presentation("sample.pptx"))
{
    presentation.Slides[0].Shapes[0].IsDecorative = true;
}
  1. Please note that the Selection Pane displays shapes in the reverse order of the Reading Order pane. This is because the Selection Pane lists objects in visual stacking order — from top to bottom — with the most recently inserted object appearing at the top of the list.
    To get a shape’s index in the Selection Pane, you can use the following code:
using (Presentation presentation = new Presentation("sample.pptx"))
{
    IShapeCollection shapes = presentation.Slides[0].Shapes;
    foreach (IShape shape in shapes)
    {
        int selectionPaneIndex = shapes.Count - shape.ZOrderPosition - 1;
        Console.WriteLine(shape.Name + ": " + selectionPaneIndex);
    }
}
  1. To change the shapes order, the IShapeCollection.Reorder method can be used.

See also:
Shape Manipulations|Aspose.Slides Documentation