70002255 Open and Save drawings as Base64 string data with web control

Article 70002255
Type HowTo
Product WebJS
Version 10
Date Added 8/29/2022 12:00:00 AM
Fixed 10.1002.0.2 (8/29/2022 12:00:00 AM)
Submitted by VectorDraw Team


Open and Save drawings as Base64 string data with web control


Example open save string data streams ,br>

        //Overwrite the vdAfterOpenDocument which will be called when New command finished
        //Overwrite the vdAfterSaveDocument which will be called after the document data stream is created
        vdcanvas.vdAfterSaveDocument = testSaveDocument;
        vdcanvas.vdAfterOpenDocument = testopenDocument;
        vdcanvas.New();//call the New so the an empty document is selected and the testopenDocument will be called

function testopenDocument() {
    vdcanvas.vdAfterOpenDocument = null;
     //we create a layer and a line reference this layer
    vdcanvas.AddLine([0, 0, 0], [3, 3, 3]);
    //save the document and finally  the testSaveDocument
function testSaveDocument(saveData) {
    vdcanvas.vdAfterSaveDocument = null;
    //get the saveData.dataStream which is a data string in base64 format and select this document to the vdcanvas
    //note: if save this drawing to a file with extension .vds is exactly like the .vds files used by the SelectDocument
    vdcanvas.SelectDocumentBlob(saveData.dataStream, "test.vds");//the passed filename is used just to set a name for the saved document to vdcanvas.GetDocument().pathname property


Send comments on this topic.