Current page orientation derived from the canvas dimensions.
Height of the page canvas in inches.
Width of the page canvas in inches.
Embed an image on the page and return the resulting Foreign shape.
Raw image bytes (PNG, JPEG, GIF, BMP, or TIFF).
Filename used to store the image inside the archive (e.g. 'logo.png').
Horizontal pin position in inches.
Vertical pin position in inches.
Display width in inches.
Display height in inches.
Add a new shape to the page and return a Shape handle to it.
Visual and text properties for the new shape.
All geometry fields (x, y, width, height) are in inches.
OptionalparentId: stringOptional ID of an existing group shape to nest the new shape inside.
// Plain rectangle
const box = await page.addShape({ text: 'Server', x: 2, y: 3, width: 2, height: 1 });
// Ellipse with styling
await page.addShape({
text: 'Start', x: 1, y: 1, width: 1.5, height: 1.5,
geometry: 'ellipse', fillColor: '#4472C4', fontColor: '#ffffff',
});
// Master instance (shape defined by a reusable master)
const m = doc.createMaster('Router', 'ellipse');
await page.addShape({ text: '', x: 4, y: 2, width: 1, height: 1, masterId: m.id });
Creates a Swimlane Lane (a Container inside a pool) and attaches it to the pool.
Creates a Swimlane Pool (a vertical List of Containers).
Remove any custom drawing scale, reverting the page to a 1:1 ratio.
Draw a connector (line/arrow) between two shapes on this page.
Source shape.
Target shape.
OptionalbeginArrow: stringArrow head at the source end (use ArrowHeads constants).
OptionalendArrow: stringArrow head at the target end (use ArrowHeads constants).
Optionalstyle: ConnectorStyleLine color, weight, pattern, and routing style.
OptionalfromPort: ConnectionTargetNamed connection point on the source shape (e.g. 'Right').
OptionaltoPort: ConnectionTargetNamed connection point on the target shape (e.g. 'Left').
import { ArrowHeads } from 'ts-visio';
const a = await page.addShape({ text: 'A', x: 1, y: 1, width: 1, height: 1 });
const b = await page.addShape({ text: 'B', x: 4, y: 1, width: 1, height: 1 });
await page.connectShapes(a, b, ArrowHeads.None, ArrowHeads.OpenArrow,
{ lineColor: '#333333', routing: 'orthogonal' });
Return all connector shapes on the page.
Each Connector exposes the from/to shape IDs, port targets, line style, arrows,
and a delete() method to remove the connector.
Return the current drawing scale, or null if no custom scale is set (1:1).
Return all layers defined on this page, ordered by index.
Works for both newly created documents and loaded .vsdx files.
Find a shape by its ID anywhere on the page, including shapes nested inside groups. Returns undefined if no shape with that ID exists.
Return all top-level shapes on the page. Group children are not included; use findShapes to search the entire shape tree.
Set a custom drawing scale for the page.
One pageScale pageUnit on paper equals drawingScale drawingUnit in the real world.
Convenience: change the page to a named standard size (portrait by default).
Rotate the canvas between portrait and landscape without changing the paper size. Swaps width and height when the current orientation does not match the requested one.
Represents a single page (tab) inside a Visio document.
Obtain a
Pageinstance from VisioDocument.pages, VisioDocument.addPage, or VisioDocument.getPage.Example