If you want to do both, you need to set a session ...
# suitescript
m
If you want to do both, you need to set a session variable or something, reload the page, and in your UE on the record, send a redirect to the suitelet to feed the pdf to the response from there.