I have a Java webapp creating a pdf and streaming it back to the browser.
byte[] pdf = report.exportPdfToArray(user);
response.setContentType("application/pdf");
response.setHeader("content-disposition", "inline; filename=\"My.pdf\"");
outStream = response.getOutputStream();
outStream.write(pdf);
outStream.flush();
outStream.close();
The report is executed and it is sent back to the browser, but I can not control the name of the file even though I set the content-disposition
.
I am using Jboss 4.2.1. Do you know what am I missing?
EDIT: So is there any way to set the filename when the content-disposition is inline?
Open the PDF document in Adobe Acrobat Pro: Select File > Properties. Select the Description tab to view the metadata in the document, including the document information dictionary. Modify the Title field to add or change the document's Title entry.
In Chrome, the filename is derived from the URL, so as long as you are using a blob URL, the short answer is "No, you cannot set the filename of a PDF object displayed in Chrome." You have no control over the UUID assigned to the blob URL and no way to override that as the name of the page using the object element.
Here's the steps of renaming PDF files or folders:Select(long press/select icon) the target PDF or folder. Tap the 'Rename' icon at the top-right corner of PDF window. Enter the new name and tap the 'Change' button to finish.
How can I serve a PDF to a browser without storing a file on the server side? But what you can do is to use the stream that is present in HttpServletResponse on server side method and write the file directly to it. Show activity on this post. You can receive an OutputStream in your generatePDF method.
content-disposition: attachment ....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With