I am using the "print" task. Not to be confused with the print widget.
import * as print from "@ArcGIS/core/rest/print.js";
The documentation says this:
But there is not a property called fileName or title on print. On the print widget, I saw TemplateOptions which had this property, but not on print.
How do I set the download filename???
The print service doesn't actually accept a custom file name for the file it generates. Instead, the Print widget works by using the link element's download property to tell the browser to save the output file with a different name.
You can reproduce this just using the print module with something like the following:
print.execute(url, printParameters).then(function(dataFile) {
fetch(dataFile.url).then(function(response) {
response.blob().then(function(blob) {
var a = document.createElement("a");
a.style.display = "none";
a.href = window.URL.createObjectURL(blob);
a.target = "_blank";
a.download = "MyFile" + dataFile.url.substring(dataFile.url.lastIndexOf("."));
document.body.appendChild(a);
a.click();
a.remove();
a = null;
});
});
});
@JoelBennett has the correct answer. I think the print known limitations doc should be updated to be more accurate for this scenario.