logo80lv
Articlesclick_arrow
Research
Talentsclick_arrow
Events
Workshops
Aboutclick_arrow
profile_loginLogIn

You Can Now Run Linux Inside A PDF File

DOOM ports have been left behind in the past.

Not too long ago, a talented high school student known as Ading2210 managed to create a port of DOOM that runs inside a PDF file, playable right in your browser. Turns out, that's just the beginning of what the popular format can do. Ading2210 took it even further by packing a pretty much functional Linux distribution inside the PDF.

This is Linux running inside a PDF file via a RISC-V emulator, which is based on TinyEMU. Working in a very similar way to the DoomPDF project, LinuxPDF can be launched in any browser on the Chromium engine with support for the PDFium library. A virtual keyboard is used to enter console commands. Both 64- and 32-bit versions are possible for the root file system. You can try LinuxPDF here and lean more about it on GitHub.

As Ading2210 explained, you might expect PDF files to only consist of static documents. Surprisingly, the PDF file format supports Javascript with its own separate standard library. Modern browsers (Chromium, Firefox) implement this as part of their PDF engines. However, the APIs available in the browser are much more limited. This allows us to do any sort of computation inside the PDF, just with some very limited IO.

C code can be compiled to run within a PDF using an old version of Emscripten that targets asm.js instead of WebAssembly. With this, the developer could compile a modified version of the TinyEMU RISC-V emulator to asm.js, which can be run within the PDF. For the input and output, they reused the same display code used for DoomPDF. It works by using a separate text field for each row of pixels on the screen, whose contents are set to various ASCII characters.

Over the years, programmers have turned some seriously unexpected objects into DOOM machines, from pregnancy tests and LEGO bricks to Windows Notepad and Blender's Geometry Nodes. It's also been run on hacking conference badges, quantum computers, and even a Microsoft Word file. Don't miss what's next from these skilled hands and join our 80 Level Talent platform and our new Discord server, follow us on InstagramTwitterLinkedInTelegramTikTok, and Threads, where we share breakdowns, the latest news, awesome artworks, and more.

Join discussion

Comments 0

    You might also like

    We need your consent

    We use cookies on this website to make your browsing experience better. By using the site you agree to our use of cookies.Learn more