How can I generate a custom powerpoint and download it in client?

1
Simply put, what I need to do is to generate a powerpoint file from scratch (better if possible from a given template, it could make work easier), add some data based on a database object and then download it in client.  What I tried to do is to follow the next resource (https://medium.com/mendix/generate-powerpoints-in-mendix-using-java-42c08ca894b4). I created a microflow which creates a FileDocument then calles a java action I created which should return me a FileDocument which is the generated PowerPoint and then I should download It.  POI --→ https://poi.apache.org/   My problem is that in the JavaAction I tried to make use of POI java library for creating powerpoints and the write function takes as a parameter a OutputStream object and what I need to do is to write to a FileDocument from which I could obtain the mendix object which can be downloaded in the client, but this is exactly my “don’t know how”.     And what I wanted to do is something like this, taken from a different JavaAction that generates a excel file
asked
3 answers
7

Below is an example of what you can do after what you already did in your code.

 

InputStream infile = new FileInputStream(file); //file is the generated file

BufferedInputStream bin = new BufferedInputStream(infile);
Core.storeFileDocumentContent(getContext(), ExcelFileParameter.getMendixObject(), file.getAbsolutePath(), bin);

bin.close();

Note that file in the code is the “MyPresentation.pptx” File object, and ExcelFileParameter is your FileDocument object that you want to download.

answered
0

My snippet java action code now generating a pptx. Thanks Firas!

answered
0

Im new to Mendix and have some questions. I am trying to export my data to a .pptx file.

What type of parameter do you use for the Json since you don't do any REST call?

Do I need to import the .jar files somehow or does mendix import them automatically when they are in the userlib folder?

answered