Retrieve and Update Presentation View Properties in C++
Introduction
In PowerPoint’s normal view, the slide appears between a side pane for thumbnails or an outline and a notes pane below. Aspose.Slides for C++ exposes the presentation’s saved editing preferences through Presentation::get_ViewProperties. These include the pane layout, zoom levels, grid spacing, and comment visibility.
About INormalViewProperties
Use get_NormalViewProperties to access the INormalViewProperties interface. set_ShowOutlineIcons controls whether icons appear beside slide titles in the outline. set_SnapVerticalSplitter lets the side pane snap to its minimized state when the user narrows it. set_PreferSingleView indicates a preference for displaying one pane in the full window.
set_VerticalBarState controls the divider between the side pane and the slide. set_HorizontalBarState controls the divider above the notes pane. Both accept a SplitterBarStateType value of Minimized, Maximized, or Restored.
About Restoring INormalViewProperties
When a divider is restored, get_RestoredLeft supplies the saved size of the side pane and get_RestoredTop supplies the saved size of the upper slide area. Both expose INormalViewRestoredProperties. Its set_DimensionSize method accepts a percentage from 0 to 100, and set_AutoAdjust controls whether the editor adjusts the size when the window is resized.
This example updates an existing presentation. It restores the horizontal divider, sets the size of the upper slide area exposed by get_RestoredTop to 80% with automatic adjustment enabled, and maximizes the vertical divider. It also enables outline icons with set_ShowOutlineIcons for outline view.
#include <DOM/INormalViewProperties.h>
#include <DOM/INormalViewRestoredProperties.h>
#include <DOM/IViewProperties.h>
#include <DOM/Presentation.h>
#include <DOM/SplitterBarStateType.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
auto presentation = System::MakeObject<Presentation>(u"demo.pptx");
auto normalView = presentation->get_ViewProperties()->get_NormalViewProperties();
normalView->set_HorizontalBarState(SplitterBarStateType::Restored);
normalView->set_VerticalBarState(SplitterBarStateType::Maximized);
auto restoredTop = normalView->get_RestoredTop();
restoredTop->set_AutoAdjust(true);
restoredTop->set_DimensionSize(80.0f);
normalView->set_ShowOutlineIcons(true);
presentation->Save(u"presentation_normal_view_state.pptx", SaveFormat::Pptx);
Set the Default Zoom Value
get_SlideViewProperties and get_NotesViewProperties store independent zoom settings for the editor. These settings do not affect slide dimensions, slide-show playback, or image export resolution.
This example opens an existing presentation and enables automatic scaling with set_VariableScale to fit the slide to the editing window. For the notes page, it disables automatic scaling and uses set_Scale to set a fixed 80% zoom.
#include <DOM/ICommonSlideViewProperties.h>
#include <DOM/IViewProperties.h>
#include <DOM/Presentation.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
auto presentation = System::MakeObject<Presentation>(u"demo.pptx");
auto viewProperties = presentation->get_ViewProperties();
viewProperties->get_SlideViewProperties()->set_VariableScale(true);
auto notesView = viewProperties->get_NotesViewProperties();
notesView->set_VariableScale(false);
notesView->set_Scale(80);
presentation->Save(u"zoom.pptx", SaveFormat::Pptx);
Set the Grid Spacing
set_GridSpacing sets the distance between editing grid lines throughout the presentation. It takes a positive value in points, with 72 points per inch. This example prints the current spacing in an existing presentation and saves a quarter-inch grid by setting the interval to 18 points.
#include <system/console.h>
#include <DOM/IViewProperties.h>
#include <DOM/Presentation.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
auto presentation = System::MakeObject<Presentation>(u"demo.pptx");
auto viewProperties = presentation->get_ViewProperties();
auto gridSpacing = viewProperties->get_GridSpacing();
System::Console::WriteLine(u"Current grid spacing: {0} points", gridSpacing);
viewProperties->set_GridSpacing(18.0f);
presentation->Save(u"grid-spacing.pptx", SaveFormat::Pptx);
The grid repeats at a fixed interval. Drawing guides mark individual horizontal or vertical positions. Both are editing aids and appear only in editors that display them. Slide shows and exports to PDF, images, or SVG omit them.
Show or Hide Comments When Opening a Presentation
set_ShowComments stores a preference that compatible editors use when opening the presentation. For an existing presentation with comments, this example prints the current setting and saves a copy with comments hidden. It also calls set_LastView with ViewType::SlideView so the copy opens in slide view.
#include <system/console.h>
#include <DOM/IViewProperties.h>
#include <DOM/NullableBool.h>
#include <DOM/Presentation.h>
#include <ViewType.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
auto presentation = System::MakeObject<Presentation>(u"comments.pptx");
auto viewProperties = presentation->get_ViewProperties();
auto showComments = viewProperties->get_ShowComments();
System::Console::WriteLine(u"Current comment visibility: {0}", showComments);
viewProperties->set_ShowComments(NullableBool::False);
viewProperties->set_LastView(ViewType::SlideView);
presentation->Save(u"comments-hidden.pptx", SaveFormat::Pptx);
Hiding comments preserves their text, authors, positions, replies, and statuses. To change the comments themselves, see Presentation Comments. Export settings control whether comments appear in PDF, HTML, images, notes, or handouts.
FAQ
Why is the grid hidden when I reopen the presentation?
The presentation stores the grid interval. To see the grid, enable grid visibility in the editor.
Does clearing drawing guides change the grid spacing?
No. Adding, moving, or clearing a guide leaves the grid interval unchanged.
Can different sections of a presentation have different view settings?
No. Presentation::get_ViewProperties applies to the entire presentation.
Can I save different view settings for different users?
The file stores one set of view properties for everyone. An editor may also apply a user’s local preferences.
Can I save view settings in a template?
Yes. Presentations created from the template inherit its saved view settings.