Nested Functions In Python Pdf Generator