Refactor pdf rendering into a class and test it #4