generate_document function

Generate the exam document