Optimized pdf export code, removed extra code