Jump to content
  • How to Render a Page to Image in Spotfire® Using IronPython Scripting


    Introduction

    Starting from Spotfire 7.12 we now have an Page.RenderAsync() which can be used to render the page an image. Below is the sample script that can be used for the same, also uncheck the "Execute in Transactipn" option in the script editor

    Code Sample

    # Copyright © 2017. TIBCO Software Inc. Licensed under TIBCO BSD-style license.
    
    import sys
    from Spotfire.Dxp.Application.Visuals import *
    from System.Drawing import Size,Image
    from System.Threading import CancellationToken
    from System.Drawing.Imaging import ImageFormat
    from System.IO import Stream,MemoryStream , File, Path
    
    page=Document.Pages[2]
    # RenderResultSettings
    rsettings=RenderResultSettings(Size(1000,750))
    rsettings.Resolution=ImageResolution.High
    #VisualRenderSettings
    vsettings=VisualRenderSettings()
    vsettings.ShowTitle=Visibility.Visible
    #PageRenderSettings
    psettings=PageRenderSettings()
    psettings.ShowTitle=Visibility.Visible
    psettings.VisualRenderSettings=vsettings
    
    
    try:
    	renderResult=page.RenderAsync(rsettings,psettings,CancellationToken(False))
    	if renderResult.Result.IsValid:
    		image=renderResult.Result.AsImage()
    		print type(image)
    		#image.Dispose()
    		
    #Temp file for storing the cross table data
    		tempFolder = Path.GetTempPath()
    		print tempFolder
    		image.Save(tempFolder+"myBitmap.bmp")
    		
    		
    except Exception , e:
    	print e.ToString()
     

    References

    License:  TIBCO BSD-Style License

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...