Refactor PDF renderer