Fix for PDF text not being selectable on Mac OSX

Produces selectable text when printing/rasterizing to PDF on OSX.

https://github.com/ariya/phantomjs/issues/10373

Please note: this PR is _almost_ the same as the original one by FreshXOpenSource: https://github.com/ariya/phantomjs/pull/11509 - the difference is that I have tried to refactor the PR to meet Contribution Guidelines and removed the filename extension check.