What is PDF Tetris?
PDF Tetris — known on GitHub as PDFtris — is Tetris running inside an ordinary-looking PDF document. There is no plugin, no canvas and no web page behind it: the falling blocks, the playfield and the score all live in the PDF file itself, driven by the small JavaScript engine that Chrome's PDF viewer ships with.
It was written by security researcher Thomas Rinsma as an experiment in how far PDF scripting can be pushed. The answer, it turns out, is "far enough to clear lines". Each cell of the 10-wide well is a form field that the script shows or hides, so the whole game is essentially a spreadsheet of checkboxes having a very good day.
If you searched for "tetris in a pdf" expecting a printable puzzle sheet, this is better: it actually plays. Hit play above, click the input box and start typing.
How to play.
- 01Open the game on a desktop computer in Chrome, Edge or Brave — their built-in PDF viewer (PDFium) runs the script.
- 02Click the small text input field on the page. The game can only hear keys typed into that box, not keys pressed anywhere else.
- 03Type W to rotate, A and D to move left and right, and S to nudge the piece down a row.
- 04Fill a complete horizontal row to clear it. Stack pieces cleanly and leave a well open for long pieces.
- 05When the stack reaches the top, the game is over. Use the reload button above the viewer to start fresh.
How it works.
PDF files can carry JavaScript that runs when the document opens. PDFtris uses that hook to start a game loop with app.setInterval, one of the few timer functions the PDF JavaScript API provides. Every tick it moves the active piece down, checks collisions against a two-dimensional field array and redraws.
Drawing is the clever part. PDF viewers don't give scripts a canvas, so the playfield is built from a grid of form-field widgets, one per cell. Redrawing means flipping each field's visibility on or off. It is slow by video-game standards but more than fast enough for Tetris.
Input comes from a text field with a keystroke action. Whenever you type a character, the viewer fires an event whose event.change property holds that character; the script's handle_input function switches on 'w', 'a', 's' and 'd' and calls rotate_piece, move_left, move_right or lower_piece. That is why the keys have to be typed into the box rather than pressed on the page.
Tips.
- Keep the cursor in the input box. If keys stop working, you've clicked away — click the box again.
- Tap keys rather than holding them; each typed character is one move, and key repeat can overshoot.
- Rotate early, while the piece is high in the well. Rotating near the stack is where most mistakes happen.
- Keep one column on the edge empty and save the long I-piece for multi-line clears.
- If pieces stutter, close other heavy tabs — the PDF engine shares a single thread with the viewer.
- Curious about the code? The full source is on GitHub and is short enough to read over a coffee.
Where it runs.
| Viewer | Status |
|---|---|
Chrome / Edge / Brave (desktop) Best experience — PDFium runs the script. | Works |
Firefox (PDF.js) PDF.js implements part of the scripting API; it may run, but behaviour and speed vary. | Partial |
Safari (macOS) Preview-style rendering, no PDF JavaScript. | No |
Adobe Acrobat Reader Supports PDF JavaScript, but we haven't verified this game there. | Partial |
iOS Safari / iPhone & iPad Mobile PDF viewers ignore PDF JavaScript entirely. | No |
Android Chrome Opens PDFs without a script engine, so nothing moves. | No |
PDF Tetris, answered.
Q1Is PDF Tetris real Tetris running in a PDF?
Yes. The game logic, the timer and the graphics all live inside the PDF file. The page you are on only embeds the document — your browser's PDF viewer does the rest.
Q2Why don't the arrow keys work?
The game reads input from a text field, and arrow keys don't type characters. Use W, A, S and D, typed into the input box.
Q3Can I download the Tetris PDF?
Yes. Use the download button on this page to save pdftris.pdf, then open it in Chrome or Edge on your computer. It is the same file you play here.
Q4Does PDF Tetris work on a phone?
No. Mobile PDF viewers on iOS and Android don't execute PDF JavaScript, so the document opens but nothing moves. Use a desktop browser.
Q5Who made PDFtris?
Thomas Rinsma. The source code is public on GitHub under ThomasRinsma/pdftris.
Q6Is it safe to open?
PDF JavaScript runs in a sandbox inside the viewer. It can't read your files or reach the network on its own. As with any download, only open PDFs from sources you trust.



