Posts

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
## 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

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 http://www.google.com/ 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 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.

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.

Hanselminutes

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.

Bitcore

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.

http://gonzalo123.com/2014/07/21/testing-phonegapcordova-applications-fast-as-hell-in-the-device-with-ionic-framework/

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.

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.

http://www.theverge.com/2014/8/7/5979573/microsoft-is-finally-killing-support-for-old-versions-of-internet

Link Post: Top 11 Best Practices for PHP Development

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://www.phpbuilder.com/articles/application-architecture/optimization/explore-the-top-11-php-best-practices.html

Link Post: Top 10 Very Very VERY Important Topics to Discuss

http://blog.jooq.org/2014/07/25/top-10-very-very-very-important-topics-to-discuss/

Link Post: Programmer's Proverbs

A good read.

https://github.com/AntJanus/programmers-proverbs

Link Post: Continuous Integration for PHP, JavaScript and Cucumber

http://www.bbc.co.uk/blogs/internet/posts/Continuous-Integration-for-PHP-JavaScript-and-Cucumber

Link Post: Why you should avoid using red asterisks

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.

https://medium.com/the-hitchhikers-guide-to-the-web/why-you-should-avoid-using-red-asterisks-12015ba2fab3

Link Post: Commit Logs From Last Night

Warning: NSFW language (if you work in a place that cares about that kind of stuff).

http://commitlogsfromlastnight.com/

RSS

Join Our Mailing List!

View previous campaigns.

Top Posts

  1. Working With Soft Deletes in Laravel (By Example)
  2. Fixing CMake was unable to find a build program corresponding to "Unix Makefiles"
  3. Upgrading to Laravel 8.x
  4. Get The Count of the Number of Users in an AD Group
  5. Multiple Vagrant VMs in One Vagrantfile
  6. Fixing the "this is larger than GitHub's recommended maximum file size of 50.00 MB" error
  7. Changing the Directory Vagrant Stores the VMs In
  8. Accepting Android SDK Licenses From The OSX Command Line
  9. Fixing the 'Target class [config] does not exist' Error
  10. Using Rectangle to Manage MacOS Windows

subscribe via RSS

All content copyright This Programming Thing 2012 - 2021
Blogging about PHP, MySQL, Zend Framework, MySQL, Server Administration and Programming in general