Skip to content
heyobiPublic

About

A PDF document that contains a working MicroPython (Python 3) shell

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

python.pdf

A PDF document that contains a working MicroPython (Python 3) interpreter. You type Python code in a fillable form field, press a button, and the output appears in a stack of read-only text fields that behave like a terminal.

How it works

The engine is MicroPython compiled to asm.js / plain JavaScript. The JavaScript engine inside a PDF viewer has no WebAssembly (WASM), so the C code is compiled to plain JavaScript using Emscripten.

The compiled engine is stored as a document-level JavaScript object, executed by the viewer when the PDF opens. A second runtime script handles the console and UI interactions. Global Python variables, functions, and state persist across executions within the session.

Output never leaves the document. Standard output and errors from Python are routed to the document's interactive form fields out0 ... out23.

Build

To build from source:

./build.sh

To test layout without waiting for compilation:

python3 generate.py --dummy --output out/skeleton.pdf

Files

  • main.c - C bridge between MicroPython embed engine and Emscripten runtime
  • pre.js - Output buffer capture and shims for PDF sandbox globals
  • runtime.js - Document-level JavaScript handling UI, button actions, and formatting
  • generate.py - Standalone PDF writer without external dependencies
  • build.sh - MicroPython embed generator and Emscripten build pipeline

Compatibility

Works in Chromium-based browsers (Google Chrome, Microsoft Edge, Brave, Arc, Opera) and Adobe Acrobat Reader.

About

A PDF document that contains a working MicroPython (Python 3) shell

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages