Technical Support Forum Index
Technical Support Forum
Access ChemAxon scientists and developers here. For registration and login issues contact website support.

Support Ticket System is replacing forum

This forum was converted into a searchable archive. You cannot add posts here any more. For support please use our new Ticket System.

Create your first ticket
Unable to get the SVG representation of the current molecule
To watch this topic for replies  Register (enables digests) or give email address:
This topic is locked: you cannot edit posts or make replies.
Display posts from previous:   
    View previous topic :: View next topic    
Author Message
Mohith

Joined: 25 Sep 2013
Posts: 26

View user's profile

Back to top
Link to postPosted: Wed Dec 18, 2013 7:33 amPost subject: Unable to get the SVG representation of the current molecule Reply with quote

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.




Peter
ChemAxon personnel
Joined: 28 Feb 2008
Posts: 310

View user's profile

Back to top
Link to postPosted: Sat Dec 21, 2013 12:40 pmPost subject: Reply with quote

Hi,

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

should work.

Cheers,

Peter

Mohith

Joined: 25 Sep 2013
Posts: 26

View user's profile

Back to top
Link to postPosted: Mon Dec 23, 2013 5:28 amPost subject: Reply with quote

Hi Peter, 

Thanks for your immediate reply. 

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

 

- MK

 


Peter
ChemAxon personnel
Joined: 28 Feb 2008
Posts: 310

View user's profile

Back to top
Link to postPosted: Mon Dec 23, 2013 11:40 amPost subject: Reply with quote

Hi,

 

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

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

Peter

Mohith

Joined: 25 Sep 2013
Posts: 26

View user's profile

Back to top
Link to postPosted: Tue Dec 24, 2013 9:12 amPost subject: Reply with quote

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. 

Peter
ChemAxon personnel
Joined: 28 Feb 2008
Posts: 310

View user's profile

Back to top
Link to postPosted: Tue Dec 24, 2013 12:21 pmPost subject: Reply with quote

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

Mohith

Joined: 25 Sep 2013
Posts: 26

View user's profile

Back to top
Link to postPosted: Fri Jan 10, 2014 6:43 amPost subject: Reply with quote

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?

Zsuzsanna
ChemAxon personnel
Joined: 12 Nov 2009
Posts: 74

View user's profile

Back to top
Link to postPosted: Fri Jan 10, 2014 9:40 amPost subject: Reply with quote

Hi Mohith,

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

Regards,

Zsuzsa

bzaicsek
ChemAxon personnel
Joined: 10 Oct 2012
Posts: 266

View user's profile

Back to top
Link to postPosted: Fri Jan 10, 2014 11:29 amPost subject: Reply with quote

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 

Nana

Joined: 22 Jan 2014
Posts: 1

View user's profile

Back to top
Link to postPosted: Wed Jan 22, 2014 4:15 amPost subject: reply Reply with quote

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

bzaicsek
ChemAxon personnel
Joined: 10 Oct 2012
Posts: 266

View user's profile

Back to top
Link to postPosted: Fri Feb 21, 2014 11:42 amPost subject: Reply with quote

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 

Mohith

Joined: 25 Sep 2013
Posts: 26

View user's profile

Back to top
Link to postPosted: Fri Sep 19, 2014 7:53 amPost subject: Reply with quote

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;
}
bzaicsek
ChemAxon personnel
Joined: 10 Oct 2012
Posts: 266

View user's profile

Back to top
Link to postPosted: Fri Sep 19, 2014 12:57 pmPost subject: Reply with quote

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 

Mohith

Joined: 25 Sep 2013
Posts: 26

View user's profile

Back to top
Link to postPosted: Sat Sep 20, 2014 7:36 amPost subject: Reply with quote

Thanks a lot, It helped me.

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

 

bzaicsek
ChemAxon personnel
Joined: 10 Oct 2012
Posts: 266

View user's profile

Back to top
Link to postPosted: Mon Sep 22, 2014 8:18 amPost subject: Reply with quote

Dear mk.laurus,

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

Regards:
Balázs 

This topic is locked: you cannot edit posts or make replies.
Page 1 of 1


To watch this topic for replies   Register (enables digests) or give email address  
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum