mark :: blog

13 Sep 2009: vCard printing with Scribus

We keep all our friends and family contacts in a single text file in vCard format. We sync this file to our phones (mobile and house DECT phones) and home automation system (for caller ID and phone book). I also print out a copy to take when travelling. Except I rarely print out an update as I've failed to find any useful program to pretty print the contacts. Previously I used a quick hack script in perl to convert the vcard entries to HTML, but it wasn't clever enough to handle page breaks and needed manual setting all the margins and page sizes correctly. I like to print it to fit in my paper planner, a Compact size Franklin Covey planner system.

I've been using Scribus for a few months, mostly for our wedding invites and stationary, and spotted that Scribus had a Python API. So a few hours later and out has popped a Python script you can use to pretty print a vCard vcf file, handling page breaks, images, and large margins to skip the hole punches.

Here is an extract from a sample vCard file:

ADR;TYPE=work:;;10 Downing Street;London;SW1A 2AA
TEL;TYPE=fax:+44 2079 250918
NICKNAME:Prime Minister
FN:Gordon Brown

You'll need a few things:

  1. a sample vCard file or your own one
  2. script (version 1.0)
  3. A recent version of Scribus. 1.3.5 works, but earlier ones will not.
  4. You'll also need the python vobject library installed if you haven't already got it

Use the "Script" "Execute Script" option, find and select and hopefully you'll end up with something like this:

You can then save it as a pdf or print it direct.

The script is a bit of a hack and has hard-coded page sizes, fonts, margins, vcard sections used, and so on. But I figure it might save someone a couple of hours and only needs a bit of modification to suit. It would be fairly easy to extend the script to use the Scribus API to let folks select the vcard file, page sizes, fonts, and things. Bonus points if you fix it to figure out the final sizes of the images and right align them. This is my second ever python program so no sniggering at the code!

Created: 13 Sep 2009
Tagged as: , ,

0 comments (new comments disabled)

Hi! I'm Mark Cox. This blog gives my thoughts and opinions on my security work, open source, fedora, home automation, and other topics.