I am using frame to load PDF. when Print action is given using javascript and clicked save option in Print Page, it shows default filename in filesavedialog which is nothing but method name from URL. I have to set different file name in Print save dialog.
Print save as dialog option shows - EmployeeReport as filename. but I have to show empid as filename in print savedialog.
I am using below code to print document in frame -
setTimeout(function () {
$('#printFrame').attr('src', "/Employee/EmployeeReport?id=" + empid);
$('#printFrame').load(function () {
window.frames['frm'].focus();
window.frames['frm'].print();
});
}, 500);
I also tried using changing title of document to empid but it still shows default file name which is nothing but url.
You are going in the right direction. You need to set the document title but you may have to play a little bit in the browser console to find the correct way. You can try setting the document title as shown below and see if works.
setTimeout(function () {
$('#printFrame').attr('src', "/Employee/EmployeeReport?id=" + empid);
$('#printFrame').load(function () {
window.frames['frm'].document.title = empid;
//OR
//document.title = empid;
window.frames['frm'].focus();
window.frames['frm'].print();
});
}, 500);
The above approach should work.