Feb 2025
By Larry
Recently there was a trend on Hacker News of putting interactive apps in pdfs—first there was Tetris, then Doom, and ultimately Linux. All of these demos utilize the primitive Javascript API exposed in browser pdf engines, particularly PDFium in Chrome and PDF.js in Firefox. These capabilities are intended for verifying user inputs in form fields and the like, but with some creativity you can make some pretty cool stuff happen.
A HN user commented that one could use this technique to put demos in resumes, showcasing one’s technical skills after asserting them. Being highly unemployed myself, I decided to take on the challenge by putting the arcade game Snake into my resume.
The difficult part here was obviously not the game itself but rather figuring out the (intentionally) obscure format of PDF files, as well as working around the limitations of the Javascript API. There are much better explanations elsewhere, but essentially you can move around the form fields and change their properties to create a primitive display. Here, I used an array of disabled text fields to display the state of the game board and another active text field as the d-pad input (WASD). Surprisingly
setInterval
is exposed in the api; this provides the game’s underlying clock. Perhaps the biggest innovation here is the integration of the app into an existing PDF. Most software generate compressed PDFs, so I had to uncompress it first before injecting my app contents into it. After that I made sure that the object ID’s don’t overlap and I simply referenced my root object in the layout of the existing page.Here’s the final PDF. Open it up in Chrome and try to beat my high score (24)—or even better, send it to your nearest recruiter and get me a job! ;)