Exporting Spotfire visualizations to template Powerpoint

33 views Asked by At

I'm trying to export the visualizations in Spotfire into a Pre-made company Powerpoint, where specific visualizations going into specific places in the Powerpoint.

I've tried following this article: "https://community.tibco.com/s/article/Exporting-Spotfire-visualization-to-PowerPoint-template?t=1703798828048" but it seems to not work and for now. For now, I have the following code that creates a Powerpoint presentations and exports all the visualizations of all pages.

import clr

clr.AddReference("System.IO")

from System.IO import *
from Spotfire.Dxp.Application.Visuals import *
from System.Drawing import Bitmap, Graphics, Rectangle, Point, Size
clr.AddReference("Microsoft.Office.Interop.PowerPoint")
import Microsoft.Office.Interop.PowerPoint as PowerPoint

powerpoint = PowerPoint.ApplicationClass()
powerpoint.Visible = True
pres = powerpoint.Presentations.Add()
slideCounter = 1

for page in Document.Pages:
    for visual in page.Visuals:
        vc = visual.As[VisualContent]()
        bm = Bitmap(800, 600)
        g = Graphics.FromImage(bm)
        r = Rectangle(Point(0, 0), bm.Size)
        vc.Render(g, r)
        file = Path.GetTempFileName()
        bm.Save(file)

        slide = pres.Slides.Add(slideCounter, PowerPoint.PpSlideLayout.ppLayoutTitleOnly)
        slideCounter += 1

        slide.Shapes.AddPicture(file, False, True, 30, 60, 650, 400)

        title = slide.Shapes.Title
        txt = slide.Shapes.AddTextBox(1, 10, 500, 500, 100)
        title.Top = 0.1
        obj = slide.Shapes.Title.TextFrame.TextRange
        obj.Font.Size = 24

Does anyone have a solution to my problem? Has followed the article mentioned above and gotten it to work?

0

There are 0 answers