There's a bug here. If ```contex.ppi``` got correctly set earlier (with a real value), and this time ```ppi == NaN```, then we won't reset context.ppi to 72.

Simple fix would be to just do ```contex.ppi = parseFloat(document.resolution)``` and then combine this if branch with the if(isNan) branch.