Retrieve and Update Presentation View Properties on Android

Introduction

The normal view consists of three content regions: the slide itself, a side content region, and a bottom content region. Properties pertaining to the positioning of the different content regions. This information allows the application to save its view state to the file, so that when reopened the view is in the same state as when the presentation was last saved.

Method IViewProperties.getNormalViewProperties has been added to provide access to normal view properties of presentation. 

INormalViewProperties, INormalViewRestoredProperties interfaces and its descendants, SplitterBarStateType enum have been added.

About INormalViewProperties

Represents normal view properties.

Methods getShowOutlineIcons and setShowOutlineIcons specifies whether the application should show icons if displaying outline content in any of the content regions of normal view mode.

Methods getSnapVerticalSplitter and setSnapVerticalSplitter specifies whether the vertical splitter should snap to a minimized state when the side region is sufficiently small.

Property getPreferSingleView and setPreferSingleView specifies whether the user prefers to see a full-window single-content region over the standard normal view with three content regions. If enabled, the application may choose to display one of the content regions in the entire window.

Methods getVerticalBarState and getHorizontalBarState specify the state that the horizontal or vertical splitter bar should be shown in. A horizontal splitter bar separates the slide from the content region below the slide, vertical splitter bar separates the slide from the side content region. Possible values are: SplitterBarStateType.Minimized, SplitterBarStateType.Maximized and SplitterBarStateType.Restored.

Methods getRestoredLeft and getRestoredTop specify the sizing of the top or side slide region of the normal view, when SplitterBarStateType.Restored value applied for getVerticalBarState and getHorizontalBarState accordingly.

About Restoring INormalViewProperties

Specifies the sizing of the slide region (width when a child of getRestoredTop, height when a child of getRestoredLeft) of the normal view, when the region is of a variable restored size (neither minimized nor maximized). 

Method getDimensionSize specifies the size of the slide region (width when a child of restoredTop, height when a child of restoredLeft).

Method getAutoAdjust specifies whether the size of the side content region should compensate for the new size when resizing the window containing the view within the application

An example is given below shows how can you access ViewProperties.getNormalViewProperties properties for a presentation.

import com.aspose.slides.*;

Presentation pres = new Presentation();
try {
    pres.getViewProperties().getNormalViewProperties().setHorizontalBarState(SplitterBarStateType.Restored);
    pres.getViewProperties().getNormalViewProperties().setVerticalBarState(SplitterBarStateType.Maximized);
    
    // Restore the view properties of the presentation
    pres.getViewProperties().getNormalViewProperties().getRestoredTop().setAutoAdjust(true);
    pres.getViewProperties().getNormalViewProperties().getRestoredTop().setDimensionSize(80);
    pres.getViewProperties().getNormalViewProperties().setShowOutlineIcons(true);

    pres.save("presentation_normal_view_state.pptx", SaveFormat.Pptx);
} finally {
    pres.dispose();
}

Set the Default Zoom Value

In order to set the view properties. Please follow the steps below:

  1. Create an instance of Presentation class.
  2. Set View Properties of Presentation.
  3. Write the presentation as a PPTX file. In the example given below, we have set the zoom value for slide view as well as notes view.
import com.aspose.slides.*;

Presentation presentation = new Presentation();
try {
    // Setting the view properties of the presentation
    presentation.getViewProperties().getSlideViewProperties().setScale(100); // Zoom value in percentages for slide view
    presentation.getViewProperties().getNotesViewProperties().setScale(100); // Zoom value in percentages for notes view 

    presentation.save("Zoom_out.pptx", SaveFormat.Pptx);
} finally {
    presentation.dispose();
}

Set the Grid Spacing

Use Presentation.getViewProperties to access presentation-wide view settings. The IViewProperties.getGridSpacing and IViewProperties.setGridSpacing methods read or change the interval of the underlying editing grid. This setting applies to the entire presentation, not to an individual slide. Grid spacing is specified in points, where 72 points equal one inch. Use a positive value, as required by the API documentation.

The following example opens an existing demo.pptx, prints its current grid spacing, sets a quarter-inch interval, and saves the result.

import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;

Presentation presentation = new Presentation("demo.pptx");
try {
    float gridSpacing = presentation.getViewProperties().getGridSpacing();
    System.out.println("Current grid spacing: " + gridSpacing + " points");

    presentation.getViewProperties().setGridSpacing(18f);
    presentation.save("grid-spacing.pptx", SaveFormat.Pptx);
} finally {
    presentation.dispose();
}

The grid is different from drawing guides. Grid spacing controls a regular interval, while drawing guides are individually positioned horizontal or vertical alignment lines. Adding, moving, or clearing drawing guides does not change the grid spacing.

Both the grid and drawing guides are editing aids. They are not rendered as slide content in PDF, images, SVG, or a slide show. Storing the grid spacing does not guarantee that an editor will display the grid: its visibility also depends on the viewer or editor’s preferences.

Show or Hide Comments When Opening a Presentation

Use Presentation.getViewProperties to access presentation-wide view settings. Use IViewProperties.getShowComments and IViewProperties.setShowComments to read or change the stored preference for whether comments should be shown when the presentation opens in PowerPoint or another compatible editor.

This setting only controls the stored view preference. It does not add, remove, edit, or resolve comments. Hiding comments preserves their content, authors, positions, replies, and statuses. See Presentation Comments for operations that change the comments themselves.

The following example requires an existing comments.pptx containing comments. It prints the current visibility setting, requests that comments be hidden, and saves a new PPTX without removing any comments. It also uses IViewProperties.setLastView with ViewType.SlideView to configure the initial editing view alongside comment visibility.

import com.aspose.slides.NullableBool;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
import com.aspose.slides.ViewType;

Presentation presentation = new Presentation("comments.pptx");
try {
    byte showComments = presentation.getViewProperties().getShowComments();
    System.out.println("Current comment visibility: " + showComments);

    presentation.getViewProperties().setShowComments(NullableBool.False);
    presentation.getViewProperties().setLastView(ViewType.SlideView);
    presentation.save("comments-hidden.pptx", SaveFormat.Pptx);
} finally {
    presentation.dispose();
}

This setting does not determine whether comments are included in PDF, HTML, image, notes, or handout exports. Configure the relevant export-specific options separately.

FAQ

Why is the grid not visible after I reopen the presentation?

The file stores the grid spacing, but the editor controls whether the grid is displayed. Check the editor’s grid visibility settings.

Does clearing drawing guides change the grid spacing?

No. Drawing guides and grid spacing are independent settings. Clearing guides leaves the stored grid interval unchanged.

Can I set different view settings for different sections of a presentation?

View settings are defined at the presentation level (Normal View/Slide View), not per section, so a single set of parameters applies to the entire document when it opens.

Can I predefine different view states for different users?

No. The settings are stored in the file and are shared. Viewer applications may honor user preferences, but the file itself contains one set of view properties.

Can I prepare a template with predefined View Properties so new presentations open the same way?

Yes. Because view properties are stored at the presentation level, you can embed them in a template and create new documents from it with the same initial view configuration.