There is a race to see who can bend the PDF file format to do the most impressive thing. Considering the more-than-30-year-old shooter, Doom, has been ported to many unexpected places, it was inevitable it would turn up in a PDF file.
The Portable Document Format (PDF) was developed to present documents in a manner that was independent of the software, hardware, and operating system showing them. It's an undoubtedly neat system, but malware authors have been known to exploit its complexity.
However, what for one person is an opportunity for mischief is for another a demonstration of programming prowess, which brings us to DoomPDF, a port of the classic first-person-shooter that will run from a PDF, assuming the PDF engine used to display the document at least partially supports PDF file format's implementation of Javascript.
The Reg ran the PDF in a Chromium browser and, purely in the interest of research, spent perhaps more time than we should making sure the monochrome rendering of '90s mayhem worked as we remembered.
According to the author, Github user ading2210, the full specification for Javascript in PDFs was only ever implemented by Adobe Acrobat, while Chromium and other browsers implemented a subset of the API surface due to security concerns. However, there is enough there to coax all manner of interactivity into life for the determined and skilled.
As for how it works, it's possible to compile C code to run in a PDF; key inputs can be grabbed and a framebuffer used for output – something the author described as a challenge.
Doom's 320 x 200 resolution meant that using individual text fields as pixels wasn't really feasible (this writer attempted to render frames using LED strips and a Raspberry Pi several years ago and… the less said about that, the better.) Instead, the port uses a separate text field for each row on the screen and sets its contents to various ASCII characters.
"I managed to get a 6 color monochrome output this way, which is enough for things to be legible in-game. The performance of this method is pretty poor but playable, since updating all of that text takes around 80ms per frame," says the dev.
- Google trains a GenAI model to simulate Doom's game engine in real-ish time
- Add bacteria to the list of things that can run Doom
- CAPTCHAs now run Doom – on nightmare mode
- Doom Eternal: Reboot sequel is cluttered but we're only here for the rippin' and the tearin'
While the frame rate might make hardcore gamers weep, it's plenty fast enough to wade Knee-Deep in the Dead.
The author said they were inspired by pdftris by Thomas Rinsma, which, as the name implies, is Tetris in a PDF. Rinsma has also attemped to bring Doom to life in PDF form but praised DoomPDF with "Great work!"
It is indeed great work and an example of some impressive ingenuity. It also highlights that PDFs are not necessarily static items, for better... or for worse.
Take care when opening a PDF, even if it promises an afternoon of '90s pixel-based action. ®