I am looking for a way to export the presentation screen to an image at any given moment in an Impress presentation.
First, I was able to open an Impress document from the command line in Python and play the presentation.
I was also able to export an image as long as all effects for a particular slide were running.
What I would like to do is export the images when there are multiple effects in a slide and I would like to export the images at the stage where each effect has been applied.
Ultimately, I would like to call the animation in which the effects play out in their own draw call and turn it into a GIF or sequentially numbered image.
If anyone has any good ideas, I would be happy to hear them.
For reference, I have included a very rough and quick sample of what we currently have.
Thank you,
Code: Select all
import argparse
import time
import uno
import os
from com.sun.star.beans import PropertyValue
def main():
parser = argparse.ArgumentParser(description="Document Saver")
parser.add_argument("src", help="Path to a Word document to be saved, e.g. path/to/hello.doc")
args = parser.parse_args()
localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext)
context = resolver.resolve("uno:socket,host=localhost,port=2083;urp;StarOffice.ComponentContext")
desktop = context.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", context)
desktop = context.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", context)
exporter = context.ServiceManager.createInstanceWithContext("com.sun.star.drawing.GraphicExportFilter", context)
# input filepath
fileUrl = uno.systemPathToFileUrl(os.path.abspath(args.src))
# open file
doc = desktop.loadComponentFromURL(fileUrl, "_blank", 0, ())
presentation = doc.getPresentation()
presentation.startWithArguments([PropertyValue(Name="IsFullScreen", Value=False)])
while True:
if presentation.isRunning():
controller = presentation.getController()
slideshow = controller.getSlideShow()
slideshow.nextEffect()
for i in range(120):
slideshow.update(1/60)
output_path = uno.systemPathToFileUrl(os.path.dirname(os.path.realpath(__file__)) + "/Slide" + str(i+1) + ".jpg")
filterData = (
PropertyValue("PixelWidth",0,1280,0),
PropertyValue("PixelHeight",0,720,0),
PropertyValue("Quality",0,100,0)
)
writeJPEG = (PropertyValue("MediaType", 0, "image/jpeg",0),
PropertyValue("URL", 0, output_path,0),
PropertyValue("Overwrite", 0, True, 0),
PropertyValue("FilterData",0,uno.Any("[]com.sun.star.beans.PropertyValue", filterData),0)
)
print("exported", output_path)
exporter.setSourceDocument(controller.getCurrentSlide())
exporter.filter(writeJPEG)