Handling both form submissions and pdf downloads