Developer Creates Tiny 60KB PDF Version of Tetris Playable in Web Browsers

· 1 min read

article picture

A creative security analyst has achieved an unexpected feat by squeezing the classic game Tetris into a mere 60KB PDF file that runs directly in web browsers. Thomas Rinsma, the developer behind this innovative project dubbed "Pdftris," has demonstrated that PDF files can do much more than display documents.

The minimalist version of the beloved puzzle game maintains the core gameplay mechanics while stripping away colors and sound effects. Players can control the falling tetriminos using either on-screen buttons or the WASD keyboard controls through an input box below the game area.

Despite its basic monochrome appearance and compact browser window display, the game successfully captures the addictive nature of the original Tetris. Players can even "save" their scores by printing the page when the game ends.

The technical achievement lies in Rinsma's clever use of PDF scripting capabilities powered by JavaScript. He utilized the show/hide functionality of PDF annotation fields to create the game's visual elements, effectively turning them into pixels for the tetriminos.

Making the game work across different PDF engines required some creative problem-solving. Rinsma developed workarounds to maintain consistent rendering and implemented an innovative approach to keyboard controls through text input events.

The entire game exists as ASCII text within the PDF file, and interested developers can examine the code by opening the file in a text editor. When asked about pushing the boundaries further, Rinsma suggested that implementing more complex games like Doom in a PDF might be possible "with the right tricks" if targeting a specific PDF engine.

This experimental project showcases the unexpected possibilities hiding within the PDF format, transforming a document standard into an unconventional gaming platform.