Why create a playable version of Tetris within a PDF? ‘Why not?’

When considering PDFs, one typically associates them with work-related documents, contracts, and unchanging images. However, this format isn’t often associated with gaming platforms. Yet, a developer named Thomas Rinsma, who works as a security analyst, took an innovative approach and developed a fully functional Tetris game within a PDF file. Although pdftris may not be the next big thing for PC gamers, it serves as an intriguing demonstration of the potential hidden in PDF files when utilized creatively.

You can enjoy playing Tetris directly from this file by opening it with a compatible web browser. It’s worth noting that Firefox and all Chromium browsers are suitable, but I found the gameplay smoother on Chrome compared to Edge. This difference might be because Edge employs Adobe Reader, which Rinsma mentions is “not fully compliant” in various aspects.

Sadly for mobile gamers, pdftris only works within desktop browsers at the moment.

As an analyst, I encountered some performance issues while playing pdftris. Loading the game in Microsoft Edge resulted in a significantly low frame rate that made it challenging to play accurately. Although the game ran smoother within Google Chrome, I noticed intermittent black lines on my screen. Nevertheless, it’s essential to understand that a project like pdftris emphasizes innovative mechanics rather than smooth gameplay.

Working on incorporating Tetris into a PDF document proved to be an enjoyable yet intriguing task, as it demanded finding a way around the differences in the engines used by two popular PDF readers – PDFium (Chromium’s PDF reader) and PDF.js (Firefox’s PDF reader).

In his post on Hacker News, Rinsma shared that it was challenging to discover common features between the two engines, but eventually found that toggling annotation “sections” effectively converts monochrome pixels, and keyboard input can be managed by typing into a text entry box.

As a project analyst, I recently read a blog post by Rinsma, who shared insights about an innovative project they’ve been working on. In this article, they address the question that I believe is on many people’s minds: “Why create Tetris within a PDF?” To put it simply, their response is, “Why not?” The inspiration behind this project stemmed from Rinsma discovering that modern desktop browser PDF engines support JavaScript and some basic input/output (I/O) primitives.

Additionally, you might want to explore the project’s code on GitHub, which demonstrates how to implement keystroke entry within a text field for controlling the subsequent blocks in pdftris.

If you’re curious, it is indeed possible to run Doom using a PDF file. The clever Rinsma figured out how to make the classic game operate within a PDF document after a bit of adjustment and tweaking.

Read More

2025-01-14 20:39