PageView object (JavaScript API for Visio)

Applies to: Visio Online

Represents the PageView class.

Properties

Property Type Description
zoom int GetSet Page's Zoom level.

Relationships

None

Methods

Method Return Type Description
centerViewportOnShape(ShapeId: number) void Pans the Visio drawing to place the specified shape in the center of the view.
fitToWindow() void Fit Page to current window.
getPosition() Position Returns the position object that specifies the position of the page in the view.
getSelection() Selection Represents the Selection in the page.
isShapeInViewport(Shape: Shape) bool To check if the shape is in view of the page or not.
load(param: object) void Fills the proxy object created in JavaScript layer with property and object values specified in the parameter.
setPosition(Position: Position) void Sets the position of the page in the view.

Method Details

centerViewportOnShape(ShapeId: number)

Pans the Visio drawing to place the specified shape in the center of the view.

Syntax

pageViewObject.centerViewportOnShape(ShapeId);

Parameters

Parameter Type Description  
ShapeId number ShapeId to be seen in the center.  

Returns

void

Examples

Visio.run(function (ctx) { 
    var activePage = ctx.document.getActivePage();
    var shape = activePage.shapes.getItem(0);
    activePage.view.centerViewportOnShape(shape.Id);
    return ctx.sync();
}).catch(function(error) {
        console.log("Error: " + error);
        if (error instanceof OfficeExtension.Error) {
            console.log("Debug info: " + JSON.stringify(error.debugInfo));
        }
});

fitToWindow()

Fit Page to current window.

Syntax

pageViewObject.fitToWindow();

Parameters

None

Returns

void

getPosition()

Returns the position object that specifies the position of the page in the view.

Syntax

pageViewObject.getPosition();

Parameters

None

Returns

Position

getSelection()

Represents the Selection in the page.

Syntax

pageViewObject.getSelection();

Parameters

None

Returns

Selection

isShapeInViewport(Shape: Shape)

To check if the shape is in view of the page or not.

Syntax

pageViewObject.isShapeInViewport(Shape);

Parameters

Parameter Type Description  
Shape Shape Shape to be checked.  

Returns

bool

load(param: object)

Fills the proxy object created in JavaScript layer with property and object values specified in the parameter.

Syntax

object.load(param);

Parameters

Parameter Type Description  
param object Optional. Accepts parameter and relationship names as delimited string or an array. Or, provide loadOption object.  

Returns

void

setPosition(Position: Position)

Sets the position of the page in the view.

Syntax

pageViewObject.setPosition(Position);

Parameters

Parameter Type Description  
Position Position Position object that specifies the new position of the page in the view.  

Returns

void

Property access examples

Visio.run(function (ctx) { 
    var activePage = ctx.document.getActivePage();
    activePage.view.zoom = 300;
    return ctx.sync();
}).catch(function(error) {
        console.log("Error: " + error);
        if (error instanceof OfficeExtension.Error) {
            console.log("Debug info: " + JSON.stringify(error.debugInfo));
        }
});