added save pdf function and modified current functions to include output mode