/ExecutablePDF

Primary LanguageJupyter Notebook

Executable PDF

Use Actually Portable Executable and inspiration from "A guide to ICO/PDF polyglot files" in Paged Out to create a PDF file that you can both view in a PDF viewer and execute from the command line.

When viewed in a PDF viewer, it's a PDF document that can contain whatever PDF content you wish to publish.

When executed from the command line, the PDF runs an executable program that is embedded in it. This can be any program you wish to compile in ape format.

Try out the example hello.pdf in Linux:

evince hello.pdf

This shows:

image

Now try running the same file from the command line, as though it was a program:

./hello.pdf

It runs, and confirms that I'm not making this whole thing up:

[mwenge@mwenge ExecutablePDF (master)]$ ./hello.pdf
I'm also a little Computer Program!

It also runs on Windows 11:

image

If you want to recreate it for yourself, try the Jupyter notebook.