I apologize that this is not strictly a LaTeX question, but I thought this StackExchange would be most suitable; all of what I describe below is done in LaTeX, BTW.
In my thesis I want to make sure that certain examples are illustrated with attached code; while I could put the code as files on my personal webpage, I would prefer if the thesis could be self-contained because you never know what might happen in 10 years: the webpage might be gone, while someone actually wants the code and has a paper/PDF version of the thesis.
However, putting too much code is pointless, because it is difficult to see someone typing 5-20 pages of code. I thought of doing something new: encoding my code using QR/Data Matrix and putting the resulting images as figures.
I was wondering how would you go about it, if at all? The style I am using for typesetting is Classic Thesis.
BTW: My initial approach would be to use square QR codes (they are most popular) of the largest possible size and stack them if necessary (vertically, two blocks per page). The QR codes would be generated automatically from live program listings using a Makefile (file.cpp -> file.pdf) and attached to the thesis project.
Comments regarding data capacity: While comments about capacity are clearly relevant here, a 144x144 square encoded as Data Matrix would contain about 2300 ASCII characters. However, using special encoding modes can bring this up to about 64,000 characters (most code is made of letters and whitespaces). Also, using 80 characters per line is a flawed methodology because multiple lines have very little to no characters. Finally, nothing stops one from using multiple squares to do the encoding.
embedfilepackage. – egreg Oct 10 '13 at 22:16