How can I generate a custom powerpoint and download it in client?
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
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);
Note that file in the code is the “MyPresentation.pptx” File object, and ExcelFileParameter is your FileDocument object that you want to download.
My snippet java action code now generating a pptx. Thanks Firas!