partridgejiang / Kekule.js

A Javascript cheminformatics toolkit.
http://partridgejiang.github.io/Kekule.js
MIT License
248 stars 61 forks source link

how can i get the img or base64 data from ChemWidget Viewer #172

Open avrahamzvv opened 4 years ago

avrahamzvv commented 4 years ago

hi i'm using ChemWidget Viewer with Tool Button editObject, i want to get the img or base64 like the CKEditor example, thanks

partridgejiang commented 4 years ago

There is a method of Viewer encapsulating that function:

var dataUri = viewer.exportToDataUri();
imgElem.setAttribute('src', dataUri);
avrahamzvv commented 4 years ago

thanks patridgejiang my finall code

var chemViewer = getChemViewer(); console.log(chemViewer.exportToDataUri( 'image/png'));