Little code cleanup

Moved variable definition to top of function in exportAsPdf() and added some whitespace where required