Prawn to turn a text file into a PDF, ready for printing.
So that's what I did. You can grab the code here, and you can see the results in the banner above.
Running it yourself
Once you've installed cahgen
(it needs the gems prawn
and trollop
, but that's it), all you need to do is make a plaintext file of questions and answers. Here's the sort of thing I'm talking about:
Vigilante justice.
Three-ply toilet paper.
Letting everyone down.
Self-loathing.
Blood.\\So much blood.
Universal fear and terror.
Hundred of bees.
You can use backslashes to indicate newlines (so the above answer card for "blood" takes up two lines, with a one-line break in the middle). Other than that, you can't do any formatting, but I haven't seen an "official" Card Against Humanity with formatting, so I'm sure you'll manage.
Output goes to output.pdf
, ready for printing. Our home printer is a somewhat senescent HP Photosmart that doesn't support duplex, so the actual process of printing (i.e. feeding in card-stock, one sheet at a time, and putting just-printed pages back in the printer to do the other side) is the most labour-intensive part of this process.
Identifying a pattern
Prawn is an amazing tool for generating PDFs. In fact, since making the above code for CaH I've built a simple letter generator for the inevitable post-Christmas correspondence to overseas relatives. I would usually write these letters in Pages, but it's always been a case of using the "least-worst" word processor available (and in my mind, Pages '11 is a UI downgrade from '09). Now I can write the letter up in my favourite text editor and convert to a fully-formatted, properly-dated, well-addressed letter in seconds.
I feel that this is an emergent pattern: replacing word processor tasks with text editor tasks, followed by conversion of plaintext to PDF. Now I've identified the pattern, I'm interested to see if there's any other tasks in my life I can convert.
Links