node-pptx
node-pptx copied to clipboard
Extract presenter notes?
How can one extract just the presenter notes? The solution which I'm using is this:
// const fs = require("fs");
const PPTX2Json = require("pptx2json");
const pptx2json = new PPTX2Json();
pptx2json.toJson("./test.pptx").then((json) => {
json = Object.keys(json)
.filter((key) => key.includes("ppt/notesSlides/notesSlide"))
.sort((a, b) => a - b)
.map((key) =>
json[key]["p:notes"]["p:cSld"][0]["p:spTree"][0]["p:sp"]
.filter((item) => item["p:txBody"])
.map((item) => item["p:txBody"][0]["a:p"])
.map((item) => item.map((item) => item["a:r"]))[0]
.filter((x) => x)
.map((item) => [
...item.reduce((prev, curr) => [...prev, curr["a:t"]], []),
])
.join(" ")
);
console.log(json);
// fs.writeFileSync("./data.txt", JSON.stringify(json));
});