heavysixer / node-pptx

Generate PPTX files on the server-side with JavaScript.
MIT License
159 stars 44 forks source link

Find/Replace text, Get list of slides containing some text #94

Open oset-bschuhma opened 2 years ago

oset-bschuhma commented 2 years ago

I have a presentation with a lot of variable placeholders that look like this: {some_variable}

I'd like to find those and replace them with the proper values (from a JSON file). I'm doing this now with docxtemplater, but I'd rather use node-pptx.

In addition, I'd like to search the presentation for the remaining instances of a variable that were not filled in - this is an indication that there's no data for that slide and it should be removed. I'd like to search for, say, "{remove_slide}" and remove that slide. I could do it with a list of slides containing that variable, then I'd sort it in descending order, then use node-pptx to delete the slides. Sorting the list descending seems like the proper path so you don't screw up the slide ordering while you're deleting slides. Maybe there's a simpler way.