Hi!
What I’m trying to do
I’m trying to generate Powerpoint slides from Obsidian, as a proof of concept for a possible plugin. However, I’m encountering a problem when integrating the module that I haven’t been able to solve yet.
I want to program slides natively and not work with generators like pandoc or plugins like slides.
First I downloaded the file “pptxgen.bundle.js” from PptxGenJS/dist at master · gitbrent/PptxGenJS · GitHub and renamed it to “pptxgen.bundle.js.md”.
Then I created a file “PowerpointUtilities.ts.md” with the following code:
```typescript
// import JSZip from "[[jszip.min.js]]"
// import pptxgen from "[[pptxgen.min.js]]"
// import {JSZip}, pptxgen from "[[pptxgen.bundle.js]]"
import {JSZip, pptxgen} from "[[pptxgen.bundle.js]]"
export function createPresentation() {
alert("HI!");
let pres = new pptxgen();
let slide = pres.addSlide();
slide.addText("Hello World from PptxGenJS...", {
x: 1.5,
y: 1.5,
color: "363636",
fill: { color: "F1F1F1" },
align: pres.AlignH.center,
});
pres.writeFile({ fileName: "Sample Presentation.pptx" });
}
And then another dataviewjs-file “Powerpoint.md” with the following code.
```dataviewjs
const module = await self.require.import("[[PowerpointUtilities.ts]]");
function clickFunction() {
module.createPresentation();
}
const button = dv.el('button', 'Generate Powerpoint');
button.onclick = () => clickFunction();
Unfortunately, I always get the error message “Evaluation Error: ReferenceError: JSZip is not defined…”
I’m at my wits’ end - what can I do?
Things I have tried
As you can see in the comments I’ve tried various methods to import, even using seperate files for jszip and pptxgen without success. Click-Buttons works when I comment out the pptxgen stuff (that´s because I´ve added the Hi-Alert).
And I’ve tried the whole scheme with JSZip only and succeeded in creating a zip file…
The Problem seems to be that pptxgen does not find the JSZip module…