Unable to get the SVG representation of the current molecule

User 4616a6b00d

18-12-2013 06:33:20

Hi,


I need to get the SVG representation of the molecule from the marvin editor. I have used the below syntax to extract the molecule data in the SVG format:


document.MSketch.getMol("svg[:image_export_options]");




My implementation code :


document.MSketch.getMol("svg[headless]");


document.MSketch.getMol("svg[:headless]");


document.MSketch.getMol("svg[':headless']");


All the above returns null/empty. Pls provide a working example.







ChemAxon d26931946c

21-12-2013 11:40:30

Hi,


document.MSketch.getMol("svg:headless");


should work.


Cheers,


Peter

User 4616a6b00d

23-12-2013 04:28:35

Hi Peter, 


Thanks for your immediate reply. 


But document.MSketch.getMol("svg:headless"); also returns null


 


- MK


 



ChemAxon d26931946c

23-12-2013 10:40:04

Hi,


 


Does  document.MSketch.getMol("smiles")  work?


Or you may try any other format (mrv, mol)


Peter

User 4616a6b00d

24-12-2013 08:12:03

Hi Peter,


Yes, 


document.MSketch.getMol("smiles") 


document.MSketch.getMol("mrv") 


document.MSketch.getMol("mol") 


All of the above works perfectly fine. As it returns the data in the specified format.


document.MSketch.getMol("svg:headless"); returns me null. Getting data in SVG format is our main requirement. 

ChemAxon d26931946c

24-12-2013 11:21:18

Hi,


 


I've tried it and converting to SVG don't work with MarvinApplets, you can only do it with MarvinBeans on the server side.


However if you want to embed images in web pages I can give you a workaround:


 


If you have an image like


<img id="molImg" /> 


in your website you can generate image to it like this:


function updateImage() {
    var imgText = document.MSketch.getMol("base64:png");
    var img = document.getElementById("molImg");
    img.src = "data:image/png;base64,"+imgText;
}


 


Please let us know if this workaround is suitable for you or you need the SVG files.


 


Cheers,


Peter

User 4616a6b00d

10-01-2014 05:43:13

Hi Peter,


Code mentioned in the above reply works well. But does not serve our purpose. We are using and implementing Marvin Applets not Marvin Beans. We need to store the file in SVG source format. So that the file can be loaded in Marvin Editor as well as viewed individually outside Marvin Editor. Is it possible to achieve this with Marvin Applets itself?

ChemAxon a202a732bf

10-01-2014 08:40:35

Hi Mohith,


I have moved the topic to the Marvin Sketch forum, our applet developers will answer your question soon.


Regards,


Zsuzsa

ChemAxon 2c555f5717

10-01-2014 10:29:11

Dear Mohith!


   Currently we can not export image formats in applet, but we already have this feature requested. I hope we can deliver this feature to you soon.


Regards:
Balázs 

User 55e91f5039

22-01-2014 03:15:03

Hi there


I am new here ,and i have encountered the similar question with you.


I want to know that if there is a powerful tool which supports to do that direclty.Thanks for any suggestions

ChemAxon 2c555f5717

21-02-2014 10:42:11

Dear Nana!


   Our next release will contain this feature.
   Until than you can try to export images by a webservice. MarvinBeans provides all possibilities to export to image formats.


Regards:
Balázs 

User 4616a6b00d

19-09-2014 06:53:42

Hi gezapeti,


We compromised on SVG, I tried the below solution, But the resolution of the PNG image will be very less. Can we set the resolution of the PNG image that is created using the below code. Image size created is very small, On specifying the height attribute of img tag, clarity of the image is lost. Please help me with this issue.


If you have an image like


<img id="molImg" /> 

in your website you can generate image to it like this:


 


function updateImage() {
var imgText = document.MSketch.getMol("base64:png");
var img = document.getElementById("molImg");
img.src = "data:image/png;base64,"+imgText;
}

ChemAxon 2c555f5717

19-09-2014 11:57:38

Dear mk.laurus,


   Unfortunately our example is currently wrong. Thank you very much for pointing it out. The fix will be in the next release. (Approximately on Tuesday or Wednesday.)


   You can find the example here: http://www.chemaxon.com/marvin/examples/applets/sketch/js_img_io.html


   You can add extra parameters to the image. About parameters you can find a documentation here: https://docs.chemaxon.com/display/FF/Image+Export+in+Marvin


   With the w and h parameters you can set a bigger image size.


   I hope, I could help


Regards:
Balázs 

User 4616a6b00d

20-09-2014 06:36:34

Thanks a lot, It helped me.


I had one more query, Can we use the document.MSketch.getMol() method for mview component ?


 

ChemAxon 2c555f5717

22-09-2014 07:18:27

Dear mk.laurus,


    You can call getM(int, String) on JMView Applet.


Regards:
Balázs