Play Tetris Inside a 60KB PDF!
WTF?! Security analyst Thomas Rinsma has crammed a playable Tetris game into a 60KB PDF file! Dubbed Pdftris, this retro marvel runs directly in your browser.
How it Works
Using the often-overlooked capabilities of PDF scripting and JavaScript, Rinsma leveraged the limited JavaScript support within PDF engines like those powering Chrome and Firefox. He cleverly used the show/hide functionality of PDF annotation fields to create the Tetris pixels, resulting in a monochrome, soundless game.
Controls are surprisingly functional. While on-screen buttons exist, keyboard controls (WASD keys) are also supported via a text input box, sending keystroke events interpreted as game actions.
Limitations and Charm
Pdftris is admittedly “janky,” but this adds to its experimental charm. The lack of color and sound enhance the retro feel. Rinsma notes that future updates could potentially incorporate these missing features.
The Future of PDF Gaming?
The code is available for viewing; you can download the PDF and examine the ASCII text within, or check out Rinsma’s GitHub repo for better-formatted code. The creator even suggests that with the right techniques, a game like Doom could potentially be squeezed into a PDF file as well!
Try Pdftris yourself and experience Tetris in a truly unique way! https://t.co/YrOInaHOUY