Aspose::Words::Settings::ViewOptions Class Reference

Detailed Description

Provides various options that control how a document is shown in Microsoft Word.

See also
Aspose::Words::Document
Aspose::Words::Document::get_ViewOptions
Examples

Shows how to set a custom zoom factor, which older versions of Microsoft Word will apply to a document upon loading.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Hello world!");
doc->get_ViewOptions()->set_ViewType(ViewType::PageLayout);
doc->get_ViewOptions()->set_ZoomPercent(50);
ASSERT_EQ(ZoomType::Custom, doc->get_ViewOptions()->get_ZoomType());
ASSERT_EQ(ZoomType::None, doc->get_ViewOptions()->get_ZoomType());
doc->Save(ArtifactsDir + u"ViewOptions.SetZoomPercentage.doc");

Shows how to set a custom zoom type, which older versions of Microsoft Word will apply to a document upon loading.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Hello world!");
// Set the "ZoomType" property to "ZoomType.PageWidth" to get Microsoft Word
// to automatically zoom the document to fit the width of the page.
// Set the "ZoomType" property to "ZoomType.FullPage" to get Microsoft Word
// to automatically zoom the document to make the entire first page visible.
// Set the "ZoomType" property to "ZoomType.TextFit" to get Microsoft Word
// to automatically zoom the document to fit the inner text margins of the first page.
doc->get_ViewOptions()->set_ZoomType(zoomType);
doc->Save(ArtifactsDir + u"ViewOptions.SetZoomType.doc");

#include <Aspose.Words.Cpp/Settings/ViewOptions.h>

+ Inheritance diagram for Aspose::Words::Settings::ViewOptions:

Public Member Functions

bool get_DisplayBackgroundShape () const
 Controls display of the background shape in print layout view. More...
 
bool get_DoNotDisplayPageBoundaries () const
 Turns off display of the space between the top of the text and the top edge of the page. More...
 
bool get_FormsDesign () const
 Specifies whether the document is in forms design mode. More...
 
ViewType get_ViewType () const
 Controls the view mode in Microsoft Word. More...
 
int32_t get_ZoomPercent () const
 Gets or sets the percentage (between 10 and 500) at which you want to view your document. More...
 
ZoomType get_ZoomType () const
 Gets or sets a zoom value based on the size of the window. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void set_DisplayBackgroundShape (bool value)
 Setter for get_DisplayBackgroundShape. More...
 
void set_DoNotDisplayPageBoundaries (bool value)
 Setter for get_DoNotDisplayPageBoundaries. More...
 
void set_FormsDesign (bool value)
 Setter for get_FormsDesign. More...
 
void set_ViewType (ViewType value)
 Setter for get_ViewType. More...
 
void set_ZoomPercent (int32_t value)
 Setter for get_ZoomPercent. More...
 
void set_ZoomType (ZoomType value)
 Setter for get_ZoomType. More...
 

Static Public Member Functions

static const TypeInfoType ()
 

Member Function Documentation

◆ get_DisplayBackgroundShape()

bool Aspose::Words::Settings::ViewOptions::get_DisplayBackgroundShape ( ) const

Controls display of the background shape in print layout view.

Examples

Shows how to hide/display document background images in view options.

// Use an HTML string to create a new document with a flat background color.
const String html = u"<html>\r\n <body style='background-color: blue'>\r\n <p>Hello world!</p>\r\n "
u"</body>\r\n </html>";
auto doc = MakeObject<Document>(MakeObject<System::IO::MemoryStream>(System::Text::Encoding::get_Unicode()->GetBytes(html)));
// The source for the document has a flat color background,
// the presence of which will set the "DisplayBackgroundShape" flag to "true".
ASSERT_TRUE(doc->get_ViewOptions()->get_DisplayBackgroundShape());
// Keep the "DisplayBackgroundShape" as "true" to get the document to display the background color.
// This may affect some text colors to improve visibility.
// Set the "DisplayBackgroundShape" to "false" to not display the background color.
doc->get_ViewOptions()->set_DisplayBackgroundShape(displayBackgroundShape);
doc->Save(ArtifactsDir + u"ViewOptions.DisplayBackgroundShape.docx");

◆ get_DoNotDisplayPageBoundaries()

bool Aspose::Words::Settings::ViewOptions::get_DoNotDisplayPageBoundaries ( ) const

Turns off display of the space between the top of the text and the top edge of the page.

Examples

Shows how to hide vertical whitespace and headers/footers in view options.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert content that spans across 3 pages.
builder->Writeln(u"Paragraph 1, Page 1.");
builder->InsertBreak(BreakType::PageBreak);
builder->Writeln(u"Paragraph 2, Page 2.");
builder->InsertBreak(BreakType::PageBreak);
builder->Writeln(u"Paragraph 3, Page 3.");
// Insert a header and a footer.
builder->MoveToHeaderFooter(HeaderFooterType::HeaderPrimary);
builder->Writeln(u"This is the header.");
builder->MoveToHeaderFooter(HeaderFooterType::FooterPrimary);
builder->Writeln(u"This is the footer.");
// This document contains a small amount of content that takes up a few full pages worth of space.
// Set the "DoNotDisplayPageBoundaries" flag to "true" to get older versions of Microsoft Word to omit headers,
// footers, and much of the vertical whitespace when displaying our document.
// Set the "DoNotDisplayPageBoundaries" flag to "false" to get older versions of Microsoft Word
// to normally display our document.
doc->get_ViewOptions()->set_DoNotDisplayPageBoundaries(doNotDisplayPageBoundaries);
doc->Save(ArtifactsDir + u"ViewOptions.DisplayPageBoundaries.doc");

◆ get_FormsDesign()

bool Aspose::Words::Settings::ViewOptions::get_FormsDesign ( ) const

Specifies whether the document is in forms design mode.

Currently works only for documents in WordML format.

Examples

Shows how to enable/disable forms design mode.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Hello world!");
// Set the "FormsDesign" property to "false" to keep forms design mode disabled.
// Set the "FormsDesign" property to "true" to enable forms design mode.
doc->get_ViewOptions()->set_FormsDesign(useFormsDesign);
doc->Save(ArtifactsDir + u"ViewOptions.FormsDesign.xml");
ASPOSE_ASSERT_EQ(useFormsDesign, System::IO::File::ReadAllText(ArtifactsDir + u"ViewOptions.FormsDesign.xml").Contains(u"<w:formsDesign />"));

◆ get_ViewType()

Aspose::Words::Settings::ViewType Aspose::Words::Settings::ViewOptions::get_ViewType ( ) const

Controls the view mode in Microsoft Word.

Although Aspose.Words is able to read and write this option, its usage is application-specific. For example MS Word 2013 does not respect the value of this option.

Examples

Shows how to set a custom zoom factor, which older versions of Microsoft Word will apply to a document upon loading.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Hello world!");
doc->get_ViewOptions()->set_ViewType(ViewType::PageLayout);
doc->get_ViewOptions()->set_ZoomPercent(50);
ASSERT_EQ(ZoomType::Custom, doc->get_ViewOptions()->get_ZoomType());
ASSERT_EQ(ZoomType::None, doc->get_ViewOptions()->get_ZoomType());
doc->Save(ArtifactsDir + u"ViewOptions.SetZoomPercentage.doc");

◆ get_ZoomPercent()

int32_t Aspose::Words::Settings::ViewOptions::get_ZoomPercent ( ) const

Gets or sets the percentage (between 10 and 500) at which you want to view your document.

If value is 0 then this property uses 100 instead, else if value is less than 10 or greater than 500 this property throws.

Although Aspose.Words is able to read and write this option, its usage is application-specific. For example MS Word 2013 does not respect the value of this option.

Examples

Shows how to set a custom zoom factor, which older versions of Microsoft Word will apply to a document upon loading.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Hello world!");
doc->get_ViewOptions()->set_ViewType(ViewType::PageLayout);
doc->get_ViewOptions()->set_ZoomPercent(50);
ASSERT_EQ(ZoomType::Custom, doc->get_ViewOptions()->get_ZoomType());
ASSERT_EQ(ZoomType::None, doc->get_ViewOptions()->get_ZoomType());
doc->Save(ArtifactsDir + u"ViewOptions.SetZoomPercentage.doc");

◆ get_ZoomType()

Aspose::Words::Settings::ZoomType Aspose::Words::Settings::ViewOptions::get_ZoomType ( ) const

Gets or sets a zoom value based on the size of the window.

Examples

Shows how to set a custom zoom factor, which older versions of Microsoft Word will apply to a document upon loading.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Hello world!");
doc->get_ViewOptions()->set_ViewType(ViewType::PageLayout);
doc->get_ViewOptions()->set_ZoomPercent(50);
ASSERT_EQ(ZoomType::Custom, doc->get_ViewOptions()->get_ZoomType());
ASSERT_EQ(ZoomType::None, doc->get_ViewOptions()->get_ZoomType());
doc->Save(ArtifactsDir + u"ViewOptions.SetZoomPercentage.doc");

Shows how to set a custom zoom type, which older versions of Microsoft Word will apply to a document upon loading.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Hello world!");
// Set the "ZoomType" property to "ZoomType.PageWidth" to get Microsoft Word
// to automatically zoom the document to fit the width of the page.
// Set the "ZoomType" property to "ZoomType.FullPage" to get Microsoft Word
// to automatically zoom the document to make the entire first page visible.
// Set the "ZoomType" property to "ZoomType.TextFit" to get Microsoft Word
// to automatically zoom the document to fit the inner text margins of the first page.
doc->get_ViewOptions()->set_ZoomType(zoomType);
doc->Save(ArtifactsDir + u"ViewOptions.SetZoomType.doc");

◆ GetType()

virtual const System::TypeInfo& Aspose::Words::Settings::ViewOptions::GetType ( ) const
overridevirtual

Reimplemented from System::Object.

◆ Is()

virtual bool Aspose::Words::Settings::ViewOptions::Is ( const System::TypeInfo target) const
overridevirtual

Reimplemented from System::Object.

◆ set_DisplayBackgroundShape()

void Aspose::Words::Settings::ViewOptions::set_DisplayBackgroundShape ( bool  value)

◆ set_DoNotDisplayPageBoundaries()

void Aspose::Words::Settings::ViewOptions::set_DoNotDisplayPageBoundaries ( bool  value)

◆ set_FormsDesign()

void Aspose::Words::Settings::ViewOptions::set_FormsDesign ( bool  value)

◆ set_ViewType()

void Aspose::Words::Settings::ViewOptions::set_ViewType ( Aspose::Words::Settings::ViewType  value)

◆ set_ZoomPercent()

void Aspose::Words::Settings::ViewOptions::set_ZoomPercent ( int32_t  value)

◆ set_ZoomType()

void Aspose::Words::Settings::ViewOptions::set_ZoomType ( Aspose::Words::Settings::ZoomType  value)

◆ Type()

static const System::TypeInfo& Aspose::Words::Settings::ViewOptions::Type ( )
static