Jump to content

How to export a mod visualization to image (png) with IronPython


WeiWei Shu 2

Recommended Posts

Hi, I have a custom mod visualization that I'd like to export to png file with IronPython script. The script below works for a native Spotfire vis, but it failed on a mod vis. I then tried Spotfire native export button (File->Export->Visualization to image...) and it works just fine. So I believe it is achievable, can anyone help me on what API function I should use to accomplish this goal Thank you!

from System.Drawing import Bitmap, Graphics, Rectangle, Point

from System.Drawing.Imaging import ImageFormat

 

for v in Document.ActivePageReference.Visuals:

w, h = 100, 100

bm = Bitmap(w, h)

g = Graphics.FromImage(bm)

g.TextRenderingHint = g.TextRenderingHint.AntiAlias

_ = v.Render(g, Rectangle(Point(0, 0), bm.Size))

fname = "G:\test.jpg"

bm.Save(fname, ImageFormat.Png)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...