PPT to JSON
Use parsePptxToJson() to turn a .pptx File into Pipto presentation data.
PPT to JSON
Use parsePptxToJson(file) when you want to load an existing PowerPoint file and convert it into the Pipto presentation format.
Import
import { parsePptxToJson } from '@henryge/pipto'Parse A Selected File
import { parsePptxToJson } from '@henryge/pipto'
async function handleUpload(file: File) {
const { presentation, warnings } = await parsePptxToJson(file)
console.log(presentation)
console.log(warnings)
}The return value is:
{
presentation: PresentationData
warnings: string[]
}Browser Example
const input = document.querySelector('input[type="file"]') as HTMLInputElement
input.addEventListener('change', async () => {
const file = input.files?.[0]
if (!file) return
const { presentation, warnings } = await parsePptxToJson(file)
console.log(presentation.slides)
console.log(warnings)
})Node-Compatible File Input
parsePptxToJson() expects a File. In Node, create one from a buffer first:
import { File } from 'node:buffer'
import { readFile } from 'node:fs/promises'
import { parsePptxToJson } from '@henryge/pipto'
const buffer = await readFile('deck.pptx')
const file = new File([buffer], 'deck.pptx', {
type: 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
})
const { presentation, warnings } = await parsePptxToJson(file)The parsed presentation can then be edited, exported again with createPPTX(), or rendered with PPTXPreviewer.