Fixing the template to show all possible cases.
Adding code to generate the PDF properly.
Fixing code to generate PDF files on materials.