It is the classic, iconic Tetris, but not as we know it.
A security analyst has taken the humble PDF and managed to adapt a version of the ever-popular title into a 60KB PDF file that can work on any browser.
As detailed by Tech Spot, Thomas Rinma is the brains behind this particular operation, dubbing his creation as “Pdftris”.
How does it work? Very simply. All you have to do is click to make the blocks fall into place, just like you did all those times before. Users can click the mouse to command the on-screen buttons, or alternatively, to use keyboard controls – WASD keys – to move, rotate, or drop.
As you would expect, there are no bells or whistles on this type of Tetris.
No colors, no sound, and no variety give a new feel to retro, but given the parameters he has worked within, it is still an impressive feat from Rinsma.
Maybe he will develop Pdftris, but to get to this stage, the analyst deployed the lesser-used capability of PDF scripting, bolstered by JavaScript.
Here's a working game of Tetris inside a PDF. Even has keyboard controls (by typing WASD in an input box). Plus, upon game-over you can "save" your score by printing the page 😉https://t.co/YrOInaHOUY
Should work in most browsers (built for pdfium/PDF.js). pic.twitter.com/n4CPcitzz9
— Thomas Rinsma (@thomasrinsma) January 5, 2025
What is under the hood?
The arduous task of delivering a working game/product was encouraged after Rinsma discovered he could make use of the PDF engines that are essential for browsers like Chrome and Firefox.
This would be the basis for his achievement.
Many hours and struggles followed as he strived to get the game to render across various PDF engines. He had to adapt and overcome, but the show/hide functionality of PDF annotation provided the breakthrough to build the famous Tetris pixels.
It is an experiment but a job very well done.
Interested users can take a look under the hood – spoiler, you will encounter the humble ASCII text – by downloading the PDF and viewing the code in an editor, or to visit Rinsma’s GitHub stash for more learning.
Hopefully, more blocks will fall into place for this clever creator as he continues his innovative, developer journey.
Image credit: Via Midjourney