@pagus-kit/core
v0.1.1
Published
PPTX parser and intermediate representation (IR) for Pagus presentations
Downloads
396
Readme
@pagus-kit/core
PPTX parser that reads .pptx files and produces a framework-agnostic intermediate representation (IR). Zero DOM dependency — runs in the browser and Node.js.
Part of the Pagus project.
Install
npm install @pagus-kit/coreUsage
import { parse } from '@pagus-kit/core'
const response = await fetch('deck.pptx')
const buffer = await response.arrayBuffer()
const presentation = await parse(buffer)
console.log(presentation.slideSize) // { width, height } in pt
console.log(presentation.slides) // Slide[]
console.log(presentation.fonts) // { usedFontFamilies, embeddedFonts }API
parse(data: ArrayBuffer): Promise<Presentation>
Parses a .pptx file and returns a Presentation object:
interface Presentation {
slideSize: Size
theme: Theme
slides: Slide[]
fonts: PresentationFonts
}IR Types
Each slide contains an array of SlideElement, a union of:
ShapeElement— rectangles, rounded rects, arrows, callouts, freeform paths, etc. with optional text bodyImageElement— embedded images as data URIsTableElement— rows, cells, merged cells, borders, and styled textChartElement— pie and doughnut charts with data pointsGroupElement— nested element containers with their own coordinate space
All types are fully exported for use with custom renderers.
Utilities
// Unit conversions
import { emuToPt, ptToPx, emuToPx, angleToDeg } from '@pagus-kit/core'
// Color operations
import { hexToRgb, rgbToHex, applyLumMod, applyTint } from '@pagus-kit/core'
// Shape geometry
import { generateShapePath, presetGenerators } from '@pagus-kit/core'Dependencies
- JSZip — ZIP extraction
- fast-xml-parser — OOXML parsing
License
MIT
