Hi Alex,
you're probably using the synchronous REST API, which directly returns
the PDF stream.
The script I mentioned before uses the asynchronous API, that means you
do an AJAX request to initiate the request and get an export job ID
back, which you may use to poll for the export status.
Once the status is at 100% you get a download URL. Point the browser
using window.location to that URL to initiate the download.
We plan to publish a template recipe soon (hopefully by end of this
week) that shows how to get a simple progress dialog when exporting from
a viewport.
Hope that helps,
Jens