:tetris:📄 You can now play Tetris in a PDF File.
[Thomas Rinsma], a security analyst and hobbyist tinkerer, recently figured out how to create a version of Tetris that runs inside a PDF file. He tackled the project “just for fun” after learning the potential implementations of PDF’s JavaScript API. The result is a novel version [Rinsma] calls PDFTRIS.
https://github.com/ThomasRinsma/pdftris
#pdf #tetris #pdftris #gaming #engineer #artist #media #javascript #programming #art #tech #news

![[ImageSource: Thomas Rinsma]
[Rinsma] explained that it’s already “relatively well-known” that PDFs can support a number of features such as dynamic content scripting when opened in something like Adobe Acrobat/Reader. Some of that same scripting support, however, is also available in both Mozilla Firefox and Google Chromium’s respective PDF readers, PDF.js and PDFium.
The PDF containing a 10×20 grid of field buttons. These alternate between shaded and empty blocks depending on the JavaScript input, allowing a player to use preprogrammed keyboard instructions to move and shift the tetronimoes — the official term for four-block shapes such as those in Tetris blocks.
“It was a bit tricky to find a union of features that work in both engines, but in the end it turns out that showing/hiding annotation ‘fields’ works well to make monochrome pixels, and keyboard input can be achieved by typing in a text input box,” [Rinsma] wrote in a post.
<https://th0mas.nl/2025/01/12/tetris-in-a-pdf/>](https://files.mastodon.social/cache/media_attachments/files/114/647/942/753/789/788/small/4abfe27a17d0fe7e.png)

