VisioArchive
At the core of the plugin lies the VisioArchive
class, which is a bridge between Microsoft Visio and JointJS. It's
main purpose is to translate a Visio vsdx archive into a VisioDocument
instance.
Methodsβ
toVSDX()β
async visioArchive.toVSDX<T extends keyof VisioArchive.ToVSDXOutputByType = 'blob'>(options?: {
type: T,
compression?: 'STORE' | 'DEFLATE',
compressionOptions?: null | {
level: number;
}
}): Promise<VisioArchive.ToVSDXOutputByType[T]>;
Use data stored in the VisioArchive instance to generate a vsdx file. This method will return a promise resulting in a vsdx file in a chosen format.
The toVSDX([opt])
method takes an object opt
with the following parameters:
typeβ
Format type in which the vsdx will be returned. By default 'blob'
type is used. Other accepted types are:
'base64'
, 'binarystring'
, 'array'
, 'uint8array'
, 'arraybuffer'
compressionβ
Compression method to use. Available options are 'STORE'
and 'DEFLATE'
. Defaults to 'STORE'
.
compressionOptionsβ
Additional compression options, ignored when using 'STORE'
method. Only available option is compression level
,
which is a number between 1 (best speed) and 9 (best compression).
const blob = await archive.toVSDX({
type: 'blob'
compression: 'DEFLATE',
compressionOptions: {
level: 9
}
});
Usageβ
const blob = await visioArchive.toVSDX({ type: 'blob' });
joint.util.downloadBlob(blob, 'project.vsdx');
A basic example of export process using default converter can be found Visio learn section.
Propertiesβ
There are several properties that can be accessed:
documentβ
visioArchive.document: VisioDocument;
The document
property holds an instance of VisioDocument of an imported vsdx archive.
sourceβ
visioArchive.source: ArrayBuffer;
The source
property holds the original archive used to create the VisioArchive
instance. It's being
stored as an ArrayBuffer.
Static Methodsβ
fromArrayBuffer()β
async fromArrayBuffer(buffer: ArrayBuffer): Promise<VisioArchive>;
Load a Visio vsdx archive from an ArrayBuffer
. This method returns a Promise.
const url = './project.vsdx';
const contentType = 'application/vnd-ms-visio.drawing;charset=utf-8';
const file = await fetch(url, { headers: { 'Content-Type': contentType }});
const arrayBuffer = await file.arrayBuffer();
const archive = await VisioArchive.fromArrayBuffer(arrayBuffer);
fromBase64()β
async fromBase64(base64: string): Promise<VisioArchive>;
Load a Visio vsdx archive from a base64
string. This method returns a Promise.
fromURL()β
async fromURL(url: string): Promise<VisioArchive>;
Load a Visio vsdx archive fetching it from a provided URL. This method returns a Promise.
const url = './project.vsdx';
const archive = await VisioArchive.fromURL(url);
A blank project that can be used to test the export process can be fetched from our documentation.
Typesβ
ToVSDXOutputByTypeβ
interface ToVSDXOutputByType {
base64: string;
string: string;
text: string;
binarystring: string;
array: number[];
uint8array: Uint8Array;
arraybuffer: ArrayBuffer;
blob: Blob;
nodebuffer: Buffer;
}