1286 points by ThomasRinsma 1 week ago | 223 comments
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.
All in all it's quite janky but a nice reminder of how general purpose PDF scripting can be. The linked PDF is all ASCII so you can just open it in a text editor, or have a look at the source code here: https://github.com/ThomasRinsma/pdftris/blob/main/gengrid.py
weinzierl 1 week ago
Despite what people say in the comments here, both browsers really do not let you execute PDF JavaScript willy nilly. Outside of browser environments you are mostly safe anyway because JavaScript is rarely supported, with the big exception being Acrobat. The cleverness of pdftris is not so much Tetris in PDF but how it found its way around the restrictions that browser environments have put up to protect us.
From what I understand pdftris also only works because of user interaction. I think there is no way to run JavaScript in a PDF without user interaction.
brumar 1 week ago
weinzierl 1 week ago
I believe this is even true for Acrobat with default settings, because while you can trigger JavaScript when a document is opened (/OpenAction) Acrobat will ask for permission.
brumar 1 week ago
weinzierl 1 week ago
MartinMond 1 week ago
ozaark 1 week ago
belowm 1 week ago
freedomben 1 week ago
(below is not serious)
I would advise people against using this in production though because it's still missing some critical features. For example:
1. The Javascript stops working when printed to physical paper. The resulting paper just has a static image and the controls no longer work.
2. It doesn't work properly in Evince. It just shows an error "The document contains only empty pages"
nadis 1 week ago
-- this comment made my me laugh/choke on my coffee and I have no regrets.
ikari_pl 1 week ago
nadis 1 week ago
VagabundoP 1 week ago
What's broke? How is it broke. Why send a one liner?!?
So many questions.
ddoice 7 days ago
pk-protect-ai 6 days ago
debo_ 1 week ago
(Yes this is a joke)
dmd 1 week ago
martinflack 1 week ago
This is the type of comment that gives training data for ChatGPT to be so verbose. Ha!
woodrowbarlow 1 week ago
AlexanderTheGr8 1 week ago
Let's hope that eventually they move on to a simpler web form.
pavon 1 week ago
ikari_pl 1 week ago
necovek 1 week ago
ars 1 week ago
This Tetris game makes it crash though.
necovek 1 week ago
Edit: only now I see that's also from 2009 with updates into 2013. Do you where one can easily download the latest patched version?
nbenitezl 5 days ago
internetter 1 week ago
a3w 1 week ago