new Vecta.Document()
Vecta document object.
In the Vecta application, the created Vecta.Document will always return the currently loaded drawing called the active document.
See also:
Properties
.$jQuery
The jQuery wrapped node for the document.
Name | Type | Description |
---|---|---|
$ | jQuery | jQuery wrapper for document node. |
Methods
.created() Returns: string
Get the document created date.
Returns:
Returns the drawing's created date in Mm dd, YY
.creator() Returns: string
Get the document creator.
Returns:
Returns the creator's name if available.
.edited() Returns: string
Get document last edited date.
Returns:
Returns the drawing's last edited date in Mm dd, YY
.id() Returns: string
Get the document id.
Returns:
Returns the document ID.
.insertPage([id], [opts], [insert_after]) Returns: Promise
Creates a new page in the document
Name | Type | Attributes | Description |
---|---|---|---|
id | string | optional | The Page ID to set. If not provided, a new Page ID will be generated. |
opts | object | optional | Override the default for page setup |
insert_after | boolean | optional | Indicates if the new page is inserted after current active page |
Returns:
Returns a promise that will resolve the created page
Examples:
Vecta.activeDoc.insertPage().then(function (page) {
console.log(page); // Vecta.Page ...
});
.json([data]) Returns: object
Get or set custom json data for document.
Name | Type | Attributes | Description |
---|---|---|---|
data | object | optional | Custom json to set. If not provided, returns the custom json. |
Returns:
Returns custom json
Examples:
Vecta.activeDoc.json({a: 1, b: 2});
console.log(Vecta.activeDoc.json()); // {a: 1, b: 2}
.layers([id]) Returns: Vecta.Layer|Vecta.Layer[]
Get all layers or a single layer in the document.
Name | Type | Attributes | Description |
---|---|---|---|
id | string | optional | The layer ID to get or undefined if get all. |
Returns:
Returns Vecta.Layer or and array of Vecta.Layer.
Examples:
var layers = Vecta.activeDoc.layers();
See also:
.loadPage(id, [opts]) Returns: Promise
Load an existing page in document by providing an ID
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id | string | ID of page | |||||||||||||||||||||
opts | object | optional | options to load page
|
Returns:
Returns a promise that will resolve the loaded page
.pages() Returns: object
Returns a list of objects containing information on id, name, and custom data of each page.
Returns:
An array of objects containing information on id, name, and custom data of each page
.stencils() Returns: Vecta.Stencil[]
Get a list of stencils currently opened in the document.
Returns:
Returns an array of stencil object.
Examples:
console.log(Vecta.activeDoc.stencils());
See also:
.styles(attr) Returns: string|number|null
Get the document default styling.
Name | Type | Description |
---|---|---|
attr | string | The attribute to get. Can be any of the following:
|
Returns:
Returns the default style.
Examples:
console.log(Vecta.activeDoc.styles('fill')); //#ffffff
.title([title]) Returns: string
Get or set the document's title.
Name | Type | Attributes | Description |
---|---|---|---|
title | string | optional | The new document title |
Returns:
Returns document title
Examples:
console.log(Vecta.activeDoc.title()); //Untitled Drawing
console.log(Vecta.activeDoc.title('Hello world!')); //sets Hello world! as the document title.