Refactor PDf renderer