Reply to a post by Jeremy Keith

Sebastian Greger

Replied to:

Print stylesheets are one more example of the assumption-puncturing nature of the web: don’t assume that everyone will be reading your content on a screen. News articles, blog posts, recipes, lyrics …there are many situations where a well-considered print stylesheet can make all the difference to the overall experience. [...] So much as I might grit my teeth, QR codes and print stylesheets make for good bedfellows.
Jeremy Keith

I full-heartedly agree with Jeremy: print stylesheets are one more feature of universal website design, and they go together rather well with QR codes …no matter how ugly, abused and underused they are.

There luckily is an alternative to Google’s Chart API (whose shutdown had been announced for 2015 last time I checked; that’s three years in the past). In true Indieweb manner, QR codes can be self-generated locally using the open source PHP library PHP QR Code. Its latest version is eight years old, but it still works like a charm - check out the print preview of this post for a proof of concept.

Here’s the piece of code I use with above library to generate mine, before caching them on the server for output:


if ( isset( $_REQUEST['url'] ) && trim( $_REQUEST['url'] ) != '' ) {

include "qrlib.php";

// a writable location, where the temp PNG files are stored

$tempdir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'temp' . DIRECTORY_SEPARATOR;

if ( !file_exists( $tempdir ) )

mkdir( $tempdir );

// sanitize URL

$url = filter_var( urldecode( $_REQUEST['url'] ), FILTER_SANITIZE_URL );

// set error correction and code size

$errcorr = 'L'; // L (low, smallest QR code) -> M -> Q -> H (highest error correction, bigger QR code)

$size = 3; // width/height per "QR pixel" in pixels

// create QR code and store PNG in temp dir

$filename = $tempdir . md5( $url .'|' . $errcorr . '|' . $size ) . '.png';

QRcode::png( $url, $filename, $errcorr, $size, 2 );

// open PNG file in binary mode

$file = fopen( $filename, 'rb' );

// send the right headers

header( "Content-Type: image/png" );

header( "Content-Length: " . filesize($filename) );

// dump the picture

fpassthru( $file );



Jeremy, maybe this allows you to prepare your talk free from any fear over a long-declared-dead Google API going away? The library even allows for SVG output, which might be neat for presentation slides - for web print styles I believe PNG to be the format with less inconsistencies.

I'm Sebastian, Sociologist and Interaction Designer. This journal is mostly about bringing toge­ther social science and design for inclusive, privacy-focused, and sustainable "human-first" digital strategies. I also tend to a "digital garden" with carefully curated resources.

My monthly email newsletter has all of the above, and there are of course also an RSS feed and Twitter.