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.
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
## RHEL
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 http://www.google.com/ output.pdf
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 http://www.google.com/ output.pdf
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 http://www.google.com/ output.pdf
The other nice thing about this is that then if someone prints the page it will also have a nice layout.
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.
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).
In this podcast they discuss the history of computer science and even include the horrors of punchcards (I'm always glad I missed these).
This podcast discusses using Improv (like Whose Line Is It Anyways) for presentations.
Lara is the Engineering Manager of Performance at Etsy and she discusses how they do their testing to see how if changes affect conversions.
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.
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.
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
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.
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.
Microsoft is planning to force Windows users onto the latest supported versions of Internet Explorer.
Yeah!!!!
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.
I'm amazed how many times I run across development environments where error handling is disabled. The other items on this list are good too.
http://blog.jooq.org/2014/07/25/top-10-very-very-very-important-topics-to-discuss/
http://www.bbc.co.uk/blogs/internet/posts/Continuous-Integration-for-PHP-JavaScript-and-Cucumber
I love this idea:
By only highlighting the optional fields, we remove almost all visual noise. This happens because a form usually has more required fields than optionals. This way, our interface is cleaner.
Warning: NSFW language (if you work in a place that cares about that kind of stuff).
subscribe via RSS