70001846 Export Script to memory string data

Article 70001846
Type Wish
Product WebJS
Version 8005
Date Added 10/21/2020 12:00:00 AM
Fixed 8.8006.0.3 (10/22/2020 12:00:00 AM)
Submitted by Bogumil Styczen


I would like to Export Script to a memory string data.


In version 8006.0.3 a new method ToScriptData has been exported to vdDocument which exports the whole document to a string array and returns a string that represents the contents of a VDS file or null if not success.
Also the method FromScriptData(string data) which gets the string data and opens the drawing.It returns true if the export was successful or false if it was not.
We are able also to pass this data to the VectorDraw WebControl through vdrawObj.SelectDocumentBlob method and load the drawing.

ToScriptData(ExportScriptFlags flags,
uint decimalPrecision,
char[] ExtraUsedChars,
int maxImageSize,
vdPrimariesList extraKeepPrimaries)

ExportScriptFlags :
Default = 0,// Default properties are used
ExplodePolylineWidths = 1, If set explode vdPolyline objects that has different segment widths.If not set vdPolyline.Widths are ignored.

decimalPrecision : The decimal precision, meaning an integer value defining how many decimal points will be considered for equality comparisons.

ExtraUsedChars : A char Array object defining characters, that are not already present in the document, and the user wants to use in the javascript webcontrol when adding new text objects.

maxImageSize : An integer that controls the maximum possible value of an image's bitmap (width x height). Default value is 552960 (a resolution of 768 * 720).

extraKeepPrimaries : A vdPrimariesList collection contains objects from the document that normally would be purged, but the user wants to keep, such as empty layers or no used blocks.

Example for ToScriptData method:

string data = ""; //keep a global string data variable
vdDocument doc = vdf.BaseControl.ActiveDocument;
data = doc.ToScriptData(vdDocument.ExportScriptFlags.Default, 6, null, 1024, null);

Example for FromScriptData method:

bool ret;
vdDocument doc = vdf.BaseControl.ActiveDocument;
ret = doc.FromScriptData(data);

Example for vdrawObj.SelectDocumentBlob method in WebControl through JavaScript:

var data = "document._d([[95,118,100,68,111,99,117,.............]])"; //the data must be something like this
vdcanvas.SelectDocumentBlob(data, "test.vds");// the data string and a filename which could not be existing.

Send comments on this topic.