Why create a playable version of Tetris within a PDF? 'Why not?'

A playable version of Tetris within a PDF file viewed in the Chrome browser.
You can play a version of Tetris within a PDF file, though you shouldn't expect smooth gameplay. (Image credit: Future)

When you think of PDFs, you probably think about work documents, contracts, and static images. The file format is not known as a gaming platform, but that's exactly how one developer decided to use it. Thomas Rinsma, a security analyst, created a fully functional version of Tetris within a PDF file. While I don't think the game, dubbed pdftris, will become a staple for PC gamers, it is an interesting hacker project that shows the capabilities of PDF files when used in a unique way.

You can play Tetris within a PDF by opening this file in a compatible browser. Rinsma notes that Firefox and all Chromium browsers are supported, though I had a better experience in Chrome than within Edge. That's likely due to the fact that Edge uses Adobe Reader, which is "not compliant in several ways," according to Rinsma.

The game does not exactly run smoothly, which is hardly a surprise. When I loaded pdftris in Edge the framerate of the game was so low I couldn't play it correctly. The game ran better within Chrome but showed some black lines across my screen. But smooth gameplay isn't what a project like pdftris is about.

Getting Tetris within a PDF was a fun project that also presented a challenge to overcome. Both PDFium, Chromium's PDF reader, and PDF.js, Firefox's PDF reader, use different engines.

"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," explained Rinsma in a post on Hacker News.

Following feedback from users and those interested in the project, Rinsma shared a blog post about the project. There, they answer the first question I imagine many people will ask, "why would you make Tetris within a PDF?" The short answer from Rinsma is "why not?" Inspiration for the project came after Rinsma realized that PDF engines in modern desktop browsers support JavaScript and some I/O primitives.

You can also check out the project on GitHub to see the code used to make keystroke-entry within a text field that allows you to control the following blocks within pdftris.

In case you were wondering, yes, a PDF can be used to run Doom. Rinsma managed to get the classic game working within a PDF after some tinkering.

Sean Endicott
News Writer and apps editor

Sean Endicott is a news writer and apps editor for Windows Central with 11+ years of experience. A Nottingham Trent journalism graduate, Sean has covered the industry’s arc from the Lumia era to the launch of Windows 11 and generative AI. Having started at Thrifter, he uses his expertise in price tracking to help readers find genuine hardware value.

Beyond tech news, Sean is a UK sports media pioneer. In 2017, he became one of the first to stream via smartphone and is an expert in AP Capture systems. A tech-forward coach, he was named 2024 BAFA Youth Coach of the Year. He is focused on using technology—from AI to Clipchamp—to gain a practical edge.