Document

Vecta.Document

new Vecta.Document()

Vecta document object. Will always returns the current document object.

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.

.json([data]) Returns: object

Get or set custom data for document

NameTypeAttributesDescription
dataobjectoptional

Custom data to set. If not given, returns custom data defined

Returns:

Returns custom data

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.

NameTypeAttributesDescription
idstringoptional

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();

.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());

.styles(attr) Returns: string|number|null

Get the document default styling.

NameTypeDescription
attrstring

The attribute to get. Can be any of the following:

stroke, stroke-width, stroke-opacity, stroke-dasharray, stroke-linecap, stroke-linejoin, fill, fill-opacity, font-family, font-size, font-weight, font-style, font-fill, font-fill-opacity, text-decoration, text-anchor, text-align

Returns:

Returns the default style.

Examples:
console.log(Vecta.activeDoc.styles('fill')); //#ffffff

.title([title]) Returns: string

Get or set the document's title.

NameTypeAttributesDescription
titlestringoptional

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.