Emilia Ortn Gmez Posted May 22, 2019 Share Posted May 22, 2019 Hi everyone! I have had some troubles when exporting visualizations type JsViz. Apparently, it exports the visualization without renderingthe js script first, and the result only shows the canvas with the initial HTML/CSS structure. In the image exported, the visualizations look the same as when I click the option 'Suspend Rendering' in the tab 'Rendering' from JS Visualization Properties. Besides, I incremented the 'Export Delay' just in case, but it doesn't work either. I am using other libraries in addition to JSViz, like Chart.js; I don't know if the problem could comefrom that. Itried to do thisvia File/Export/... and also via IronPython scripting with the code below, but the problem persists in both cases. import sys from System.IO import * from Spotfire.Dxp.Application.Visuals import * from System.Drawing import Size, Image from System.Drawing.Imaging import ImageFormat from System.Threading import CancellationToken from System.Threading import Thread from Spotfire.Dxp.Framework.ApplicationModel import ApplicationThread app = Application.GetService[ApplicationThread]() pages=Document.Pages # RenderResultSettings rsettings=RenderResultSettings(Size(1225,700)) rsettings.Resolution=ImageResolution.High #VisualRenderSettings vsettings=VisualRenderSettings() vsettings.ShowTitle=Visibility.Visible #PageRenderSettings psettings=PageRenderSettings() psettings.ShowTitle=Visibility.Visible psettings.VisualRenderSettings=vsettings def asyncshot(pages): def f(): for page in pages: #print page.Title Document.ActivePageReference = page for visual in page.Visuals: try: renderResult=visual.RenderAsync(rsettings,vsettings,CancellationToken(False)) if renderResult.Result.IsValid: image=renderResult.Result.AsImage() #print type(image) #image.Dispose() tempFolder = Path.GetTempPath() print tempFolder image.Save(tempFolder+page.Title+visual.Title+".bmp") except Exception , e: print 'Error: ' + e.ToString() return f() app.InvokeAsynchronously(asyncshot(pages))Also, I tried this code (with 'Render' method which isdeprecated), but it gave me a similar result. from System.IO import * from Spotfire.Dxp.Application.Visuals import VisualContent from System.Drawing import Bitmap, Graphics, Rectangle, Point for visual in Document.ActivePageReference.Visuals: #print visual.Title #export graphic to temp file vc = visual.As[VisualContent]() bm = Bitmap(2000, 1200) g = Graphics.FromImage(bm) r = Rectangle(Point(0,0), bm.Size) vc.Render(g, r) file = Path.GetTempFileName() print(file) bm.Save(file) Link to comment Share on other sites More sharing options...
Colt Street Posted June 13, 2019 Share Posted June 13, 2019 Did you ever find an answer to this Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now