npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

python-pptx-wasm

v0.0.1

Published

A WASM JavaScript library for manipulating PowerPoint presentations via Python-pptx and pyodide.

Readme

python-pptx-wasm

NPM Version NPM License codecov

A WASM JavaScript library for manipulating PowerPoint presentations via python-pptx and Pyodide.


Features

  • ✅ Read/write .pptx presentations with the full python-pptx API
  • ✅ WebAssembly-powered via Pyodide
  • ✅ Works in browser and Node.js
  • ✅ Intelligent type inference

Install

  1. Install dependencies:
$ npm install --save python-pptx-wasm pyodide
  1. Download the latest recipes (packages.tar.gz) from python-pptx-recipe, and extract them into a fixed location, e.g.: project_root/assets/recipes

Usage

import fs from 'node:fs';
import { loadPyodide } from 'pyodide';
import { init, Presentation } from 'python-pptx-wasm';

const main = async () => {
  const pyodide = await loadPyodide({
    // Assuming recipes are extracted into `project_root/assets/recipes`
    lockFileURL: `project_root/assets/recipes/pyodide-lock.json`
  });

  await init(pyodide);

  const prs = Presentation();
  const slide1 = prs.slides.add_slide(prs.slide_layouts[0]);
  slide1.shapes.title!.text = 'Slide 1 Title';

  
  prs.save((buffer) => {
    // handle file buffer here
    fs.writeFileSync(`output_file.pptx`, buffer);
  });

  prs.end()
}

main()

Use with Bundler

If you are using a bundler in a web environment (e.g., Vite):

  1. Download and extract recipes into public/recipes.

  2. Install Vite plugin and update vite.config.ts:

$ npm install vite-plugin-static-copy @types/node --dev
// vite.config.ts
import { defineConfig } from "vite";
import { viteStaticCopy } from "vite-plugin-static-copy";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";

const PYODIDE_EXCLUDE = [
  "!**/*.{md,html}",
  "!**/*.d.ts",
  "!**/*.whl",
  "!**/node_modules",
];

export function viteStaticCopyPyodide() {
  const pyodideDir = dirname(fileURLToPath(import.meta.resolve("pyodide")));
  return viteStaticCopy({
    targets: [
      {
        src: [join(pyodideDir, "*")].concat(PYODIDE_EXCLUDE),
        dest: "assets",
      },
    ],
  });
}

export default defineConfig({
  plugins: [viteStaticCopyPyodide()],
  optimizeDeps: { exclude: ["pyodide"] }
});
  1. Inside the codes:
import { loadPyodide } from 'pyodide';
import { init, Presentation } from 'python-pptx-wasm';

const main = async () => {
  const baseURL = window.location.origin + import.meta.env.BASE_URL

  // full url is required by pyodide
  const pyodide = await loadPyodide({
    indexURL: `${baseURL}assets`,
    // Assuming recipes are extracted into `public/recipes`
    lockFileURL: `${baseURL}recipes/pyodide-lock.json`
  });

  await init(pyodide);

  const prs = Presentation();
  const slide1 = prs.slides.add_slide(prs.slide_layouts[0]);
  slide1.shapes.title!.text = 'Slide 1 Title';

  // save file in browser
  prs.save((buffer) => {
    // buffer will be a Unit8array
    // @ts-ignore
    const blob = new Blob([buffer], { type: "application/vnd.openxmlformats-officedocument.presentationml.presentation" });
    const a = document.createElement("a");
    a.href = url;
    a.download = 'output_file.pptx';
    document.body.appendChild(a);
    a.click();
    document.body.removeChild(a);
    URL.revokeObjectURL(url);
  });

  prs.end()
}

main()

Technical Details

  1. Differences from python-pptx

    python-pptx-wasm reimplements all core classes and method signatures of python-pptx in JavaScript, and calls the actual Python code via a Pyodide bridge.

    Note: The part components from python-pptx are not implemented.

  2. The end() method

    Since python-pptx runs inside Pyodide, memory is not released automatically.

    When using python-pptx-wasm, you must manually call end() to free it:

    import { Presentation } from 'python-pptx-wasm';
    
    // Assuming already initialized
    const prs = Presentation();
    
    // ...
    // Perform operations on prs
    
    // Release memory
    prs.end()
  3. File handling

    Unlike python-pptx, you cannot pass a file path directly.

    In python-pptx-wasm, all files are handled and passed as Uint8Array buffers:

    import fs from 'node:fs';
    import { Presentation } from 'python-pptx-wasm';
    
    // Assuming already initialized
    // Read a file as Uint8Array
    const prs = Presentation(new Uint8Array(fs.readFileSync(`existed_file.pptx`)));
    
    prs.end()
  4. Length units

    python-pptx-wasm reimplements the length unit helpers from python-pptx:

    • Length
    • Centipoints
    • Cm
    • Emu
    • Inches
    • Mm
    • Pt

    Example:

    import { Presentation, Emu } from 'python-pptx-wasm';
    import { MSO_AUTO_SHAPE_TYPE } from 'python-pptx-wasm/pptx/enum';
    
    // Assuming already initialized
    const prs = Presentation();
    
    // Create a new slide
    const slide = prs.slides.add_slide(prs.slide_layouts[6]);
    
    // Add a shape using Emu for size/position
    slide.shapes.add_shape(MSO_AUTO_SHAPE_TYPE.RECTANGLE, Emu(914400), Emu(914400), Emu(1828800), Emu(914400));
    
    prs.end()

License

MIT License