ChemDraw JS 17.1 API Reference Guide Chem Draw
User Manual: Pdf
Open the PDF directly: View PDF .
Page Count: 45
- Global Objects
- Classes
- ChemDrawDirect
- addProduct(cdxml) : number
- addReactant(cdxml) : number
- addReagent(cdxml) : number
- clear() : void
- convertToCDXML(content, mimeType, callback) : void
- findReactions(callback) : void
- fitToContainer() : void
- getAllFragmentsInfo([options]) : Array<FragmentInfo>
- getB64CDX() : string
- getCDXML() : string
- getCanvasSize() : Size
- getDocumentName() : string
- getErrors() : Array<string>
- getFragmentsInfo([options]) : Array<FragmentInfo>
- getImgUrl() : string
- getInChI(callback) : void
- getInChIKey(callback) : void
- getMOL(callback) : void
- getMOLV3000(callback) : void
- getMolecularWeight(content, mimeType, callback) : void
- getProperties(callback) : void
- getRXN(callback) : void
- getRXNV3000(callback) : void
- getSMILES(callback) : void
- getSVG(callback) : void
- getSelectedFragmentsInfo([options]) : Array<FragmentInfo>
- getVersion() : string
- isBlankStructure() : boolean
- isSaved() : boolean
- labelFragments(ids) : void
- loadB64CDX(b64CDX, callback) : void
- loadCDXML(cdxml) : void
- loadConfig(config) : void
- loadConfigFromUrl(url, callback) : void
- loadMOL(mol, callback) : void
- loadSMILES(smiles, callback) : void
- markAsSaved() : void
- nameToStructure(name, callback) : void
- setCanvasSize(size[, options]) : void
- setContentChangedHandler(handler) : void
- setDocumentName(name) : void
- setViewOnly(viewOnly) : void
- structureToName(cdxml, callback) : void
- ChemDrawDirect
- JSON Structures
- Callbacks

PerkinElmer
ChemDraw®JS as a Service 17.1
API Reference Guide
Last Updated: January 22, 2018

Table of Contents
Global Objects 8
perkinelmer.ChemdrawWebManager 8
attach(options) : void 8
Parameters 8
Returns 8
Example 8
Classes 9
ChemDrawDirect 9
addProduct(cdxml) : number 9
Parameters 9
Returns 9
Example 9
addReactant(cdxml) : number 9
Parameters 10
Returns 10
Example 10
addReagent(cdxml) : number 10
Parameters 10
Returns 10
Example 10
clear() : void 11
Parameters 11
Returns 11
Example 11
convertToCDXML(content, mimeType, callback) : void 11
Parameters 12
Returns 12
Example 12
findReactions(callback) : void 12
Parameters 13
Returns 13
Example 13
fitToContainer() : void 13
Parameters 13
Returns 13
Example 14
getAllFragmentsInfo([options]) : Array<FragmentInfo> 14
Parameters 14
Returns 14
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 2 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Example 14
getB64CDX() : string 15
Parameters 15
Returns 15
Example 15
getCDXML() : string 15
Parameters 15
Returns 15
Example 15
getCanvasSize() : Size 16
Parameters 16
Returns 16
Example 16
getDocumentName() : string 16
Parameters 16
Returns 16
Example 17
getErrors() : Array<string> 17
Parameters 17
Returns 17
Example 17
getFragmentsInfo([options]) : Array<FragmentInfo> 17
Parameters 18
Returns 18
Deprecated 18
Example 18
getImgUrl() : string 18
Parameters 18
Returns 18
Example 19
getInChI(callback) : void 19
Parameters 19
Returns 19
Example 19
getInChIKey(callback) : void 20
Parameters 20
Returns 20
Example 20
getMOL(callback) : void 20
Parameters 21
Returns 21
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 3 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Example 21
getMOLV3000(callback) : void 21
Parameters 21
Returns 21
Example 22
getMolecularWeight(content, mimeType, callback) : void 22
Parameters 22
Returns 22
Example 22
getProperties(callback) : void 23
Parameters 23
Returns 23
Example 23
getRXN(callback) : void 24
Parameters 24
Returns 24
Example 24
getRXNV3000(callback) : void 25
Parameters 25
Returns 25
Example 25
getSMILES(callback) : void 25
Parameters 26
Returns 26
Example 26
getSVG(callback) : void 26
Parameters 26
Returns 26
Example 27
getSelectedFragmentsInfo([options]) : Array<FragmentInfo> 27
Parameters 27
Returns 27
Example 27
getVersion() : string 28
Parameters 28
Returns 28
Example 28
isBlankStructure() : boolean 28
Parameters 28
Returns 28
Example 29
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 4 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

isSaved() : boolean 29
Parameters 29
Returns 29
Example 29
labelFragments(ids) : void 29
Parameters 30
Returns 30
Example 30
loadB64CDX(b64CDX, callback) : void 30
Parameters 30
Returns 30
Example 30
loadCDXML(cdxml) : void 31
Parameters 31
Returns 31
Example 31
loadConfig(config) : void 31
Parameters 32
Returns 32
Example 32
loadConfigFromUrl(url, callback) : void 32
Parameters 32
Returns 32
Example 32
loadMOL(mol, callback) : void 33
Parameters 33
Returns 33
Example 33
loadSMILES(smiles, callback) : void 34
Parameters 34
Returns 34
Example 34
markAsSaved() : void 35
Parameters 35
Returns 35
Example 35
nameToStructure(name, callback) : void 35
Parameters 35
Returns 35
Example 35
setCanvasSize(size[, options]) : void 36
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 5 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Parameters 36
Returns 36
Example 36
setContentChangedHandler(handler) : void 37
Parameters 37
Returns 37
Example 37
setDocumentName(name) : void 37
Parameters 38
Returns 38
Example 38
setViewOnly(viewOnly) : void 38
Parameters 38
Returns 38
Example 38
structureToName(cdxml, callback) : void 39
Parameters 39
Returns 39
Example 39
JSON Structures 40
ApplicationProperties 40
Properties 40
AttachOptions 40
Properties 40
Configuration 40
Properties 41
ContentChangedEvent 41
Properties 41
Features 41
Properties 41
FragmentInfo 41
Properties 41
GetFragmentsInfoOptions 42
Properties 42
SetCanvasSizeOptions 42
Properties 42
Size 42
Properties 42
Tool 42
Properties 43
ToolGroup 43
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 6 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Properties 43
ToolsLayout 43
Properties 43
Callbacks 44
AttachCallback 44
Parameters 44
ConfigLoadCallback 44
Parameters 44
ContentChangedHandler 44
Parameters 44
ErrorCallback 44
Parameters 44
GetNumberCallback 44
Parameters 45
GetTextContentCallback 45
Parameters 45
LoadDocumentCallback 45
Parameters 45
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 7 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Global Objects
perkinelmer.ChemdrawWebManager
The singleton global object to manage ChemDraw JS instances.
attach(options) : void
Creates a new ChemDraw JS tool and attaches it to the specified DOM node. The attach function may be used to
attach several instances of ChemDraw to the DOM and may be called at any time. The ChemDraw instance
cannot be used immediately once this functions returns. A callback function can be specified in the input JSON
object. Then it can be called after the instance becomes available. Please refer to the Developers Guide for details.
Parameters
Name Type Description
options AttachOptions which is object contains some parameters to configure ChemDraw JS
Returns
void
Example
var chemdrawjs;
function chemDrawAttached(chemdrawweb) {
// Implement your own logic here, call API
chemdrawjs= chemdrawweb;
}
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: chemDrawAttached
});
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 8 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Classes
ChemDrawDirect
Provides APIs to manage the ChemDraw document, canvas and drawings on the canvas.
addProduct(cdxml) : number
Appends a new product to the reaction present in the current drawing. If there are products present, the new product
will be added to the right of the right-most product. If no reaction is present, a new arrow will be added to the center
of the canvas along with the product.
Parameters
Name Type Description
cdxml string the CDXML string
Returns
number the ID of the new product
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs= chemdrawweb;
}
});
chemdrawjs.addProduct("CDXML content...");
addReactant(cdxml) : number
Appends a new reactant to the reaction present in the current drawing. If there are reactants present, the new
reactant is added to the left of the left-most reactant. If no reaction is present, a new arrow is added to the center of
the canvas along with the reactant.
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 9 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Parameters
Name Type Description
cdxml string the CDXML string
Returns
number the ID of the new reactant
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs= chemdrawweb;
}
});
chemdrawjs.addReactant("CDXML content...");
addReagent(cdxml) : number
Appends a new reagent to the reaction present in the current drawing. The reagent is added to the top of the
reaction arrow and above the top-most reagent if there are any already. If no reaction is present, a new arrow is
added to the center of the canvas, along with the reagent.
Parameters
Name Type Description
cdxml string the CDXML string
Returns
number the ID of the new reagent
Example
var chemdrawjs;
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 10 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.addReagent("CDXML content...");
clear() : void
Clears all drawings on the ChemDraw canvas. This operation is not undoable. And ChemDraw will not prompt the
user to confirm the operation.
Parameters
None
Returns
void
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.clear();
convertToCDXML(content, mimeType, callback) : void
Converts structure string to CDXML format.
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 11 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Parameters
Name Type Description
content string the structure string
mimeType string the string format type, ex: chemical/x-cdx, chemical/x-mdl-
molfile, chemical/x-helm
callback GetTextContentCallback the callback function to be called after the result is generated
Returns
void
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.convertToCDXML("Structure content...", "Structure mine type...", function (cdxml,
error) {
if (!error) {
// deal with result
} else {
// deal with error
}
});
findReactions(callback) : void
Returns reactions information of the current drawing. This call is asynchronous and a callback function must be
provided that is informed when the results are available.
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 12 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Parameters
Name Type Description
callback GetTextContentCallback function when finish loading
Returns
void
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.findReactions(function (reactions, error) {
if (!error) {
// deal with result
} else {
// deal with error
}
});
fitToContainer() : void
Resizes ChemDraw instance to fit to the container.
Parameters
None
Returns
void
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 13 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.fitToContainer();
getAllFragmentsInfo([options]) : Array<FragmentInfo>
Gets information of all fragments on the canvas which contains CDXML string and preview PNG picture.
Parameters
Name Type Description
options GetFragmentsInfoOptions Optional the options for getting fragments information
Returns
Array<FragmentInfo> an array of fragments information which contains CDXML string and preview PNG picture
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
var fragmentsInfo = chemdrawjs.getAllFragmentsInfo();
var cdxml = fragmentsInfo.cdxml;
var image = fragmentsInfo.image;
// ...
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 14 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

getB64CDX() : string
Returns a CDX base64 string representing the current drawing.
Parameters
None
Returns
string a CDX base64 string representing the current drawing
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
var b64cdx = chemdrawjs.getB64CDX();
getCDXML() : string
Returns a CDXML string representing the current drawing.
Parameters
None
Returns
string a CDXML string representing the current drawing
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 15 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

chemdrawjs = chemdrawweb;
}
});
var cdxml = chemdrawjs.getCDXML();
getCanvasSize() : Size
Gets ChemDraw JS's current canvas size.
Parameters
None
Returns
Size ChemDraw JS's current canvas size
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
var size = chemdrawjs.getCanvasSize();
var width = size.width;
var height = size.height;
getDocumentName() : string
Gets the underlying document name which is saved in the CDXML.
Parameters
None
Returns
string the underlying document name which is saved in the CDXML
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 16 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
var name = chemdrawjs.getDocumentName();
getErrors() : Array<string>
Returns an array of strings describing the chemical errors that are present in the current drawings.
Parameters
None
Returns
Array<string> an array of strings describing the chemical errors that are present in the current drawings
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
var errors = chemdrawjs.getErrors();
getFragmentsInfo([options]) : Array<FragmentInfo>
Gets fragments information which contains CDXML string and preview PNG picture.
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 17 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Parameters
Name Type Description
options GetFragmentsInfoOptions Optional the options for getting fragments information
Returns
Array<FragmentInfo> an array of fragments information which contains CDXML string and preview PNG picture
Deprecated
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
var fragmentsInfo = chemdrawjs.getFragmentsInfo();
var cdxml = fragmentsInfo.cdxml;
var image = fragmentsInfo.image;
// ...
getImgUrl() : string
Returns a URL string which points to a PNG representation of the current drawing. The image contents are
encoded in the URL so that it can be used offline.
Parameters
None
Returns
string a URL string which points to a PNG representation of the current drawing
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 18 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
var imageUrl = chemdrawjs.getImgUrl();
getInChI(callback) : void
Translates the current drawing into an InChI representation. This call is asynchronous. A callback function can to
be provided and it will be invoked after the result is generated.
Parameters
Name Type Description
callback GetTextContentCallback the callback function to be called after the result is generated
Returns
void
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.getInChI(function (inchI, error) {
if (!error) {
// deal with result
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 19 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

} else {
// deal with error
}
});
getInChIKey(callback) : void
Translates the current drawing into an InChIKey representation. This call is asynchronous. A callback function can
to be provided and it will be invoked after the result is generated.
Parameters
Name Type Description
callback GetTextContentCallback the callback function to be called after the result is generated
Returns
void
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.getInChIKey(function (inchIKey, error) {
if (!error) {
// deal with result
} else {
// deal with error
}
});
getMOL(callback) : void
Translates the current drawing into a MOL v2000 representation. This call is asynchronous. A callback function can
to be provided and it will be invoked after the result is generated.
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 20 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Parameters
Name Type Description
callback GetTextContentCallback the callback function to be called after the result is generated
Returns
void
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.getMOL(function (mol, error) {
if (!error) {
// deal with result
} else {
// deal with error
}
});
getMOLV3000(callback) : void
Translates the current drawing into a MOL v3000 representation. This call is asynchronous. A callback function can
to be provided and it will be invoked after the result is generated.
Parameters
Name Type Description
callback GetTextContentCallback the callback function to be called after the result is generated
Returns
void
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 21 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.getMOLV3000(function (molv3000, error) {
if (!error) {
// deal with result
} else {
// deal with error
}
});
getMolecularWeight(content, mimeType, callback) : void
Gets molecular weight of the structure.
Parameters
Name Type Description
content string the structure string
mimeType string the string format type, ex: chemical/x-cdx, chemical/x-mdl-molfile, chem-
ical/x-helm
callback GetNumberCallback the callback function to be called after the result is generated
Returns
void
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 22 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.getMolecularWeight("Structure content...", "Structure mine type...", function
(weight, error) {
if (!error) {
// deal with result
} else {
// deal with error
}
});
getProperties(callback) : void
Returns properties of the current drawing. This call is asynchronous. A callback function can to be provided and it
will be invoked after the result is generated.
Parameters
Name Type Description
callback GetTextContentCallback the callback function to be called after the result is generated
Returns
void
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.getProperties(function (props, error) {
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 23 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

if (!error) {
// deal with result
} else {
// deal with error
}
});
getRXN(callback) : void
Translates the current drawing into a RXN v2000 representation. This call is asynchronous. A callback function can
to be provided and it will be invoked after the result is generated.
Parameters
Name Type Description
callback GetTextContentCallback the callback function to be called after the result is generated
Returns
void
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.getRXN(function (rxn, error) {
if (!error) {
// deal with result
} else {
// deal with error
}
});
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 24 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

getRXNV3000(callback) : void
Translates the current drawing into a RXN v3000 representation. This call is asynchronous. A callback function can
to be provided and it will be invoked after the result is generated.
Parameters
Name Type Description
callback GetTextContentCallback the callback function to be called after the result is generated
Returns
void
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.getRXNV3000(function (rxnv3000, error) {
if (!error) {
// deal with result
} else {
// deal with error
}
});
getSMILES(callback) : void
Translates the current drawing into a SMILES representation. This call is asynchronous. A callback function can to
be provided and it will be invoked after the result is generated.
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 25 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Parameters
Name Type Description
callback GetTextContentCallback the callback function to be called after the result is generated
Returns
void
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.getSMILES(function (smiles, error) {
if (!error) {
// deal with result
} else {
// deal with error
}
});
getSVG(callback) : void
Translates the current drawing into a SVG representation. This call is asynchronous. A callback function can to be
provided and it will be invoked after the result is generated.
Parameters
Name Type Description
callback GetTextContentCallback the callback function to be called after the result is generated
Returns
void
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 26 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.getSVG(function (svg, error) {
if (!error) {
// deal with result
} else {
// deal with error
}
});
getSelectedFragmentsInfo([options]) : Array<FragmentInfo>
Gets information of the selected fragments on the canvas which contains CDXML string and preview PNG picture.
Parameters
Name Type Description
options GetFragmentsInfoOptions Optional the options for getting fragments information
Returns
Array<FragmentInfo> an array information of the selected fragments on the canvas which contains CDXML string
and preview PNG picture
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 27 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

}
});
var fragmentsInfo = chemdrawjs.getSelectedFragmentsInfo();
var cdxml = fragmentsInfo.cdxml;
var image = fragmentsInfo.image;
// ...
getVersion() : string
Returns the current version of ChemDraw as a string.
Parameters
None
Returns
string the current version of ChemDraw
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
var version = chemdrawjs.getVersion();
isBlankStructure() : boolean
Returns true if nothing has been drawn in ChemDraw and false if something has been drawn.
Parameters
None
Returns
boolean true if nothing has been drawn in ChemDraw and false if something has been drawn
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 28 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
var isBlank = chemdrawjs.isBlankStructure();
isSaved() : boolean
Determines if there is any unsaved change.
Parameters
None
Returns
boolean true if there is any unsaved change, otherwise false
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
var isSaved = chemdrawjs.isSaved();
labelFragments(ids) : void
Auto-number the fragments of the reaction with Roman numeral labels. Any existing labels will be replaced with the
new ones.
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 29 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Parameters
Name Type Description
ids Array<number>the array of the fragments to be labelled
Returns
void
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.labelFragments([1, 2, 3]);
loadB64CDX(b64CDX, callback) : void
Reads a BASE64 encoded CDX string and loads its contents into ChemDraw. This call is asynchronous. A
callback function can to be provided and it will be invoked after the loading is done.
Parameters
Name Type Description
b64CDX string the CDX base64 encoded string
callback LoadDocumentCallback function when finish loading
Returns
void
Example
var chemdrawjs;
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 30 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.loadB64CDX("CDX base64 content...");
loadCDXML(cdxml) : void
Reads a CDXML string and loads its contents into ChemDraw.
Parameters
Name Type Description
cdxml string the CDXML string
Returns
void
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.loadCDXML("CDXML content...");
loadConfig(config) : void
Applies a new configuration into ChemDraw.
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 31 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Parameters
Name Type Description
config string ¦Configuration the configuration json object or json string
Returns
void
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.loadConfig("Configuration JSON string");
// chemdrawjs.loadConfig({}); or Configuration JSON Object
loadConfigFromUrl(url, callback) : void
Applies a new configuration from remote url into ChemDraw.
Parameters
Name Type Description
url string the remote configuration file url
callback ConfigLoadCallback when finished, this function will be called
Returns
void
Example
var chemdrawjs;
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 32 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.loadConfigFromUrl("remote configuration file url", function (error) {
// if error is undefined configuration is done
// if error isn't undefined, it shows the error message during the loading progress
});
loadMOL(mol, callback) : void
Reads a MOL string and loads its contents into ChemDraw. This call is asynchronous. A callback function can to
be provided and it will be invoked after the loading is done.
Parameters
Name Type Description
mol string the MOL string
callback LoadDocumentCallback function when finish loading
Returns
void
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.loadMOL("MOL content...", function (cdxml, error) {
if (!error) {
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 33 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

// deal with result
} else {
// deal with error
}
});
loadSMILES(smiles, callback) : void
Reads a SMILES string and loads its contents into ChemDraw. This call is asynchronous. A callback function can
to be provided and it will be invoked after the loading is done.
Parameters
Name Type Description
smiles string the SMILES string
callback LoadDocumentCallback function when finish loading
Returns
void
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.loadSMILES("SMILES content...", function (cdxml, error) {
if (!error) {
// deal with result
} else {
// deal with error
}
});
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 34 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

markAsSaved() : void
Sets the dirty flag to indicate the canvas is saved and clean.
Parameters
None
Returns
void
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.markAsSaved();
nameToStructure(name, callback) : void
Reads a structure name and returns a CDXML string representing the structure.
Parameters
Name Type Description
name string the name of the structure to be converted
callback GetTextContentCallback the callback function to be called after converting is done
Returns
void
Example
var chemdrawjs;
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 35 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.nameToStructure("structureName", function (cdxml, error) {
if (!error) {
// deal with result
} else {
// deal with error
}
});
setCanvasSize(size[, options]) : void
Sets ChemDraw JS canvas size.
Parameters
Name Type Description
size Size the new canvas size
options SetCanvasSizeOptions Optional the options to configure the canvas size
Returns
void
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 36 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

var size = {
width: 100,
height: 100
};
var options = {
doNotCropDrawings: false
};
chemdrawjs.setCanvasSize(size, options);
setContentChangedHandler(handler) : void
Sets a callback function which will be invoked when user makes any change on the canvas.
Parameters
Name Type Description
handler ContentChangedHandler the callback function
Returns
void
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.setContentChangedHandler(function (event) {
// Implement your own logic here
});
setDocumentName(name) : void
Sets the document name to the resulting CDXML.
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 37 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Parameters
Name Type Description
name string the document name to set
Returns
void
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.setDocumentName("document name");
setViewOnly(viewOnly) : void
Sets whether the user is able to interact with ChemDraw.
Parameters
Name Type Description
viewOnly boolean indicator the ChemDraw JS instance is view only or not
Returns
void
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 38 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.setViewOnly();
structureToName(cdxml, callback) : void
Reads a CDXML string and returns the name of the structure.
Parameters
Name Type Description
cdxml string the CDXML string to be converted
callback GetTextContentCallback the callback function to be called after converting is done
Returns
void
Example
var chemdrawjs;
perkinelmer.ChemdrawwebManager.attach({
id: "chemdrawjsContainer",
callback: function (chemdrawweb) {
chemdrawjs = chemdrawweb;
}
});
chemdrawjs.structureToName("CDXML content...", function (name, error) {
if (!error) {
// deal with result
} else {
// deal with error
}
});
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 39 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

JSON Structures
ApplicationProperties
Application properties
Properties
Name Type Description
StyleSheet string The name of the default document stylesheet
chemservice string The end point of the ChemDraw web service
AttachOptions
The options for creating and attaching a new ChemDraw JS instance
Properties
Name Type Description
callback AttachCallback Optional The callback function to be invoked after the new ChemDraw JS
instance is attached
config Configuration Optional The configuration JSON object
configUrl string Optional The URL to a remote configuration file
element HTMLElement Optional The object of the HTML element to be attached to
errorCallback ErrorCallback Optional The callback function when ChemDraw JS is failed to load or
attach
id string Optional The ID of the HTML element to be attached to
license string Optional The license file content to initialize ChemDraw JS
licenseUrl string Optional The license file URL to initialize ChemDraw JS
preservePageInfo boolean Optional Determines the view mode of ChemDraw JS
viewonly boolean Optional Determines the initial state of ChemDraw JS (view only or edit-
able)
Configuration
The ChemDraw JS configuration
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 40 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Properties
Name Type Description
appProperties ApplicationProperties Other application properties
features Features Feature toggles
layout ToolsLayout Toolbar layout
ContentChangedEvent
The event for content change handler
Properties
Name Type Description
action string The action name
Features
Features
Properties
Name Type Description
disabled Array<string> The list of disabled features
enabled Array<string> The list of enabled features
FragmentInfo
Structure information on the canvas
Properties
Name Type Description
cdxml string The structure CDXML string
height number The structure height
id number The fragment id
image string The structure preview PNG picture encoded in BASE64
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 41 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Name Type Description
width number The structure width
xnumber The structure location x
ynumber The structure location y
GetFragmentsInfoOptions
Options for getting fragments information
Properties
Name Type Description
borderSize number Optional The size of the border
transparentBackground boolean Optional Determines if the background should be transparent or not
SetCanvasSizeOptions
The option for setting canvas size
Properties
Name Type Description
doNotCropDrawings boolean Optional Determines whether crop the drawing when change the canvas size.
Size
The size object contains width and height
Properties
Name Type Description
height number height in pixel
width number width in pixel
Tool
Tool
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 42 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Properties
Name Type Description
order Array<string ¦ToolGroup> Configure tool item order, it could be single tool or group tool
ToolGroup
Group tool instance
Properties
Name Type Description
collapse string Collapse mode:"auto", "always", "never"
columns string The number of columns of the expanded tool group panel
group string The name of the tool group
order Array<string> The order of the sub tools
writingMode string Optional The layout mode of the expanded tool group panel: "horizontal", "ver-
tical"
ToolsLayout
Tools layout
Properties
Name Type Description
orientation string Toolbar orientation. "Horizontal", "Vertical"
tools Array<Tool> The list of tools or tool groups
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 43 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Callbacks
AttachCallback
A callback function which is called after ChemDraw JS is attached
Parameters
Name Type Description
cdd ChemDrawDirect the new instance of ChemDraw JS
ConfigLoadCallback
A callback function which is called after a new configuration is loaded
Parameters
Name Type Description
error string Optional the error message during the loading process
ContentChangedHandler
The callback function which will return the event
Parameters
Name Type Description
event ContentChangedEvent the action description when does changes on canvas
ErrorCallback
Callback function indicating error happens.
Parameters
Name Type Description
error Error The error detail
GetNumberCallback
The callback function which will return the number and error
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 44 of 45
ChemDraw JS as a Service 17.1: API Reference Guide

Parameters
Name Type Description
value number the result number
error string the error message if any exception occurs
GetTextContentCallback
The callback function which will return the string and error
Parameters
Name Type Description
content string the result string
error string the error message if some exceptions occur
LoadDocumentCallback
The callback function which will return the CDXML string and error
Parameters
Name Type Description
cdxmlStr string the CDXML string
error string the error message if some exceptions occur
© Copyright 1998-2018 PerkinElmer Informatics, Inc. All rights reserved. 45 of 45
ChemDraw JS as a Service 17.1: API Reference Guide