WWDC 2008 Session PDF Generator in Ruby

Posted on 13 May 2008 by Johannes Fahrenkrug. Tags: Programming WWDC Ruby
Update: Thanks to Brett from TUAW I could update the script so it now works with the new structure of the sessions.xml file from Apple.
WWDC 2008 is coming up next month! The sessions sound very interesting and it will be difficult to choose. The Apple website with the session info is great, but since the whole thing is "ajaxified" some browsers have trouble printing the session schedule. And yes: I am one of those guys who wants a printed page to scribble on. I need that. To think and to doodle and to eventually circle or mark the sessions I'm going to attend. So I looked at the source for the session page and found the XML with the session info and a JavaScript file with some more info. The next step was just to simply make a PDF file from this. With Ruby, that's quite easy. This is what I came up with:
#!/usr/bin/env ruby

# WWDC 2008 Session PDF Generator, 2008 by Johannes Fahrenkrug.
# No licence, do with it what you want
# http://springenwerk.com

require 'rexml/document'
require 'open-uri'
require 'FPDF'
require 'fpdf/table'

class FPDF
  include Fpdf::Table

TRACKS = { 16 => 'iPhone',
           15 => 'Mac',
         17 => 'IT' 
  33 => 'Essentials',
  37 => 'Getting Started',
  34 => 'Integration',
  35 => 'Media',
  36 => 'Tools' 
  33 => 'Lab',
  31 => 'Session' 

puts 'WWDC 2008 Session PDF Generator by Johannes Fahrenkrug'
print 'Getting sessions.xml file...'

file = open('http://developer.apple.com/wwdc/data/sessions.xml')

if file
  puts 'OK'
  print 'Parsing XML...'
  xml = REXML::Document.new(file)
  if xml
    puts 'OK'
    print 'Generating PDF...'  
    data = []
    xml.elements.each("//item") do |c|
      line = []
      linestr = c.attributes['name'] + " (#{c.attributes['id']})\n" 

      c.elements.each do |sub_element|
        if sub_element.name == 'theme'
          themes = ''
          if sub_element.text
            sub_element.text.split(',').each do |theme| 
                themes += TRACKS[theme.to_i] + ' '
                # unknown track
          linestr += "Tracks: #{themes}\n" if themes.size > 0

        if sub_element.name == 'track'
          linestr += "Theme: #{CATEGORIES[sub_element.text.to_i]}\n"
        if sub_element.name == 'type'
          linestr += "Type: #{TYPES[sub_element.text.to_i]}\n"
You just have to download it here, unzip it and run the program. That's it: You'll have a great ugly text PDF waiting to be printed. This is a very limited tool, I know, so please feel free to enhance it!


luigi193 said...

It didn't work for me...

But it DID work when i put it in ~ weird.

May 16, 2008 07:01 PM

Anonymous said...

Um... It didn't work for me...

But I moved it out of the downloaded folder and into
~ and it worked fine THERE

May 16, 2008 06:56 PM

Johannes Fahrenkrug said...

Thanks, guys! I just fixed it. Note to self: double check download links next time ;-)

May 13, 2008 11:37 AM

Anonymous said...

Hi, the download link isn't working at the moment

May 13, 2008 11:35 AM

The boy Ken said...

Hi, the download link isn't working

May 13, 2008 11:32 AM


Please keep it clean, everybody. Comments with profanity will be deleted.

blog comments powered by Disqus