Read Node Core Text and Edit Powerpoint Presentations with the Details #1803
-
Currently in my job I need to make powerpoint presentations that will typically have certain items[name, date, background on project, etc.] in the same locations. Usually this is the first two slides in certain text boxes. I often put this info in my Freeplane map as I use it to track a project before I then put it in a presentation to finalize. I also have files to manage in-between so it just also further helps in viewing all I have with a project. However, it would be nice to be able to have all this that I already write automatically extracted and placed into a PowerPoint presentation in the places I want. I'm familiar enough with scripting to know how to extract the text from node cores and some other items to say I'm not too unfamiliar with coding. So far I've been able to move folder data, add links to nodes with folders of the same name as the node core text, and automatically create folders with the names of my node core text. However, I am still a novice ,especially when it comes to using libraries. I know of Apache POI as a start and know I need to download the .jav files. I did that, but it seemed to fail despite me going through to see if I got possibly all the .jav files I could need. Probably don't need all of this but I followed this guide to make extra sure Tutorialpoints: C:\poi-bin-5.1.0\poi-5.1.0.jar; Now, what I know is that I downloaded the most up to date versions of these which may be the problem. But, I know the process of trying to figure out what is ideal correct for what version can be annoying. So before I go back to figure out what is needed for apachepoi 5.2.5 (the version I have) or go down a version, I had wanted to step back and ask if what I am doing is correct or is there a better way to accomplish what I'm planning on doing. Suggestions, hints, etc. would also be helpful as well. Mainly see this as an open discussion to see how to use Freeplane scripts to read node core text and take those details and put them in specific locations of a powerpoint template. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
It's an interesting usecase. If I understood correctly, the Apache POI creates and edit the ppt file directly. Another approach is to use a ppt template with dynamic fields (fields that are filled automatically, from an external source), and then export the nodes text to a file, that will be used as a source for the dynamic fields. This script is a simple example of how to interact with an external file: #1640 (comment) But, maybe Apache POI is indeed the best tool for the job. |
Beta Was this translation helpful? Give feedback.
-
Freeplane uses Groovy as its scripting language. This means that we can use Groovy magic to make things simpler (as compared to coding in Java), in particular I've never used POI, so I need to rely on a tutorial – I've chosen https://www.baeldung.com/apache-poi-slideshow
The window will freeze for a minute while Grape grabs the jars (and their dependencies) from the internet. This is done only once, i.e. subsequent executions will be faster. Check in the directory where your mind map is located for the newly created @Grab('org.apache.poi:poi:5.2.5')
@Grab('org.apache.poi:poi-ooxml:5.2.5')
import org.apache.poi.xslf.usermodel.SlideLayout
import org.apache.poi.xslf.usermodel.XMLSlideShow
def ppt = new XMLSlideShow()
ppt.createSlide()
def defaultMaster = ppt.slideMasters[0]
def layout = defaultMaster.getLayout(SlideLayout.TITLE_AND_CONTENT)
def slide = ppt.createSlide(layout)
def titleShape = slide.getPlaceholder(0)
titleShape.text = node.text
def contentShape = slide.getPlaceholder(1)
contentShape.text = node.children.collect { it.text }.join('\n')
def file = new File(node.mindMap.file.parent, 'powerpoint.pptx')
if (!file.exists()) {
file.withDataOutputStream { outputStream ->
ppt.write(outputStream)
}
ui.showMessage("$file has been created", 1)
} else {
ui.showMessage("$file already exists", 0)
} Alternatively, you can use Grape on the command line (in a terminal) to install the jars to a directory of your choosing. You need to have Groovy installed on your system, though.
Once Grape is done, search Note: You can use |
Beta Was this translation helpful? Give feedback.
Freeplane uses Groovy as its scripting language. This means that we can use Groovy magic to make things simpler (as compared to coding in Java), in particular
@Grab
.I've never used POI, so I need to rely on a tutorial – I've chosen https://www.baeldung.com/apache-poi-slideshow
Tools->Edit script…
, thenActions->New script
Actions->Run
The window will freeze for a minute while Grape grabs the jars…