If it is possible to edit the toolbar test this:
<a href="download/document.pdf" download="nome_desejado">Download PDF</a>
Based on your comment I decided to edit the reply!
After analyzing an open pdf in Firefox, I noticed that it loaded a js called "Viewer.js" and it looks interesting function inside it:
function getPDFFileNameFromURL(url) {
var reURI = /^(?:([^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
// SCHEME HOST 1.PATH 2.QUERY 3.REF
// Pattern to get last matching NAME.pdf
var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
var splitURI = reURI.exec(url);
var suggestedFilename = reFilename.exec(splitURI[1]) ||
reFilename.exec(splitURI[2]) ||
reFilename.exec(splitURI[3]);
if (suggestedFilename) {
suggestedFilename = suggestedFilename[0];
if (suggestedFilename.indexOf('%') !== -1) {
// URL-encoded %2Fpath%2Fto%2Ffile.pdf should be file.pdf
try {
suggestedFilename =
reFilename.exec(decodeURIComponent(suggestedFilename))[0];
} catch(e) { // Possible (extremely rare) errors:
// URIError "Malformed URI", e.g. for "%AA.pdf"
// TypeError "null has no properties", e.g. for "%2F.pdf"
}
}
}
return suggestedFilename || 'document.pdf';
}
Ready, now you know how it brings the default name "Document.pdf".
Excellent question. I can’t imagine how to do that!
– Caio Felipe Pereira
This might help, http://stackoverflow.com/questions/7717851/save-file-javascript-with-file-name
– David
@David, in my case the problem is that the toolbar is created dynamically via HTML 5, and each Browser behaves in a different way, making it impossible to use hint given in the link you posted.
– Jedaias Rodrigues
@Sanction is a link.
– Jedaias Rodrigues