Refactored render as pdf.