Field vdAfterSaveDocument
- Namespace
- vdWebLibrary
- Assembly
- JsPropertiesExtractor.dll
Get/Set a method that called after a document is successfully saved and can be handled by a function described by the vdAfterSaveDocumentDelegate.
public vdAfterSaveDocumentDelegate vdAfterSaveDocument
Returns
- vdAfterSaveDocumentDelegate
- Get/Set a method that called after a document is successfully saved and can be handled by a function described by the .
Examples
Open a drawing and save it to default download folder
var vdcanvas; // keep the vdcanvas control global for quick access inside the functions since it is the only one in the this page
function vdrawInitPageLoad()//Intiallize the web control inside this function.It must be called inside onload event of this page
{
vdmanager.AttachCanvas("canvas"); //create a new web control andattch it to the canvas elemement
vdcanvas = vdmanager.vdrawObject(); //return a refence to the attached web control
vdcanvas.vdAfterOpenDocument = _vdAfterOpenDocument; //defines the function that will be fire when a web control document loaded.
vdcanvas.vdAfterSaveDocument = _vdAfterSaveDocument; //defines the function that will be fire when a web control document data saved completed.
}
function _vdAfterOpenDocument()
{
vdcanvas.SaveDocument();
}
function _vdAfterSaveDocument(saveData)
{
var textFile = null;
makeTextFile = function (text) {
var data = new Blob([text], { type: 'octet/stream' /*'text/plain'*/ });
// If we are replacing a previously generated file we need to
// manually revoke the object URL to avoid memory leaks.
if (textFile !== null) {
window.URL.revokeObjectURL(textFile);
}
textFile = window.URL.createObjectURL(data);
return textFile;
};
var link = document.createElement('a');
var path = saveData.dataObject.pathname;//get the filename of original open drawing
if(!path) path = 'vdDocument.vds';
var n = path.lastIndexOf("/");
if (n >= 0) path = path.substr(n + 1);
link.setAttribute('download', path);
link.href = makeTextFile(saveData.dataStream);//get the stream data
document.body.appendChild(link);
// wait for the link to be added to the document
window.requestAnimationFrame(
function () {
var event = document.createEvent("MouseEvents");
event.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
link.dispatchEvent(event); //call a mouse click to start download the saved data
document.body.removeChild(link);
}
);
}