I'm not sure what I'm following. If you want the contents of the PDF to be sent to the browser, you must use an instance of HttpResponse . This line in your code
outputStream = file("document-output.pdf", "wb")
will not help to write the contents of the PDF in response. Instead, it seems to me that it will write the contents to a local file, which is not the same.
Update
Based on the comment:
How to send PDF content to an HttpResponse object since it will be opened in a browser, not as an attachment.
AFAIK (if anyone knows better, correct me), it depends on the browser.
If you do not specify Content-Disposition = "attachment; filename=foo.pdf from the response headers, you can send the contents to the browser without a specific file name. This caused my Firefox browser (3.6.10, Ubuntu Jaunty) to ask me if I want whether I open it using the program.In Chrome (6.0.472.62, Ubuntu Jaunty) the file loaded as download.pdf without any prompts.
Manoj govindan
source share