Preventing Tables From Printing Across Pages

Don’t ask me why but some people actual print things (I know who the hell are these people). One of my clients came to me because one of their users was printing a report and the tables looked like this:

They wanted to know if there was anything I could do to keep it from printing like this. My first comment was not to print it but they didn’t think that was funny. In order to fix this I added the following to the CSS (actually the SCSS) for their site:

@media only print {
        page-break-inside: avoid;

This tells the browser to avoid having page breaks inside a table when printing the results look like this:

It still has problems when the table is larger than a piece of paper but there’s really only so much you can do when it comes to printing.

Improve wkhtmltopdf Issues

On several of the projects that I maintain we have to create a PDF export of something (usually reports and invoices). I always find that the quickest, least painful way of doing this is to use wkhtmltopdf to convert an HTML page to a PDF. Until recently, it’s been an abandoned project (I’ve been using 0.11 for years) and I’m happy to say that it’s been updated to 0.12 recently! I also learned a couple new things.

Run the process through x11

I’ve run into a couple of problems with pages not rendering correctly and in order to fix them I had to run the process with an X11 server. I don’t want a GUI running on my server so I run the process through xvfb.

First you need to install the executable:

## Unbuntu
sudo apt-get install xvfb
sudo yum install xorg-x11-server-Xvfb

And then the command line is a little more complicated:

xvfb-run --server-args="-screen 4, 1280x1024x24" wkhtmltopdf --use-xserver output.pdf

Debug Javascript

If you’re like me and have to run some JavaScript in order to generate graphs you can run into problems that are hard to troubleshoot because of the headless nature of wkhtmltopdf. You can add the --debug-javascript option and it will print any console functions to stderr.

xvfb-run --server-args="-screen 4, 1280x1024x24" wkhtmltopdf --use-xserver --debug-javascript output.pdf

Specify print media type

If you run wkhtmltopdf normally it will create a PDF of the screen exactly as you see it. This is nice but you can also specify that wkhtmltopdf set the media type to print (@media print) so you can specify a different look for the PDF:

xvfb-run --server-args="-screen 4, 1280x1024x24" wkhtmltopdf --use-xserver --print-media-type output.pdf

The other nice thing about this is that then if someone prints the page it will also have a nice layout.

More Podcasts!!!!

I recently purchased a house (which is why this blog has basically be a link post machine [sorry]) and have been doing a lot of home improvement projects and getting caught up on my podcasts as I work. I thought I would highlight a couple of the more interesting ones I’ve heard.


If you listen to podcasts, are a developer, and don’t listen to Hanselminutes you really should. Scott Hanselman works for Microsoft so his podcast occasionally has a Microsoft bent but he also has some amazing interviews with people from around the community. I don’t think I’ve ever skipped one of his podcasts.

What it really means to be Junior Developer with Jonathan Barronville

In this podcast they talk about what it means to be a Junior vs Senior developer and how important it is to always be learning (I agree with this totally).

Stories of Computer Science Past and Present with Len Bass

In this podcast they discuss the history of computer science and even include the horrors of punchcards (I’m always glad I missed these).

Applying Improv to Agile and Lean Startup models with Jessie Shternshus

This podcast discusses using Improv (like Whose Line Is It Anyways) for presentations.

Designing for Performance with Lara Swanson

Lara is the Engineering Manager of Performance at Etsy and she discusses how they do their testing to see how if changes affect conversions.

Shop Talk Show

Another awesome podcast that any website developer should listen to. They’re focused on frontend development but it’s helpful to know about this if you’re a backend developer or like me have to do both.

Shop Talk Show 127: WITH TOBIAS GĂśNTHER

In this episode they talk with the CEO of a company that makes an OSX GUI for git and they discuss version control in general. I’m actually going to try their software Tower instead of GitHub for OS X.

FLOSS Weekly

Another excellent podcast to listen to if your a sysadmin. It really highlights a lot of cool projects that I’ve actually used because of the show

The Big 300

FLOSS Weekly hit episode 300! It’s interesting to listen to the history of the show because I remembered when it started years ago.


This is an interesting episode about Bitcore which is a JavaScript library for interacting with the Bitcoin network. I don’t have a need for this but other people might.

Link Post: Testing Phonegap/Cordova applications fast as hell in the device (with ionic framework)

I haven’t actually tried this but because of his article I’m going to use Ionic Framework for my next mobile app. Ionic’s based on PhoneGap/Cordova and AngularJS so you can develop cross-phone (if that’s not a phrase it should be) software quickly. The part I like most about is so far is that you can run:

 ionic serve

And it automatically starts up a server, starts a browser tab with your app, and injects LiveReload into your Ionic app for super fast development.

Link Post: Microsoft is finally killing support for old versions of Internet Explorer

Microsoft is planning to force Windows users onto the latest supported versions of Internet Explorer.


The change will take effect on January 12th, 2016

Damn it!

The article says IE 8 and 10 won’t be support anymore but 8 was already EOLed so I’m guessing it’s supposed to be 9.