Currently I'm working on an app where a dialog pops up with details of an item being received (the user just inputs the amount received). The user inputs the changes (amount received) and then saves. Once saved, I prompt the user to create a pdf via confirmation (the client wanted to see changes in a hard copy). The pdf is correctly generated and offered to the user via an Open/Save/Cancel dialog.
My question is, is there a way to just force the pdf to open automatically without the prompt to Open/Save/Cancel? The reason why is I want to be able to shut the dialog behind the scenes as the pdf pops up so the user doesn't have to close it themselves.
Below is what I have so far.
View
$.getJSON('@Url.Action("ReceiveProduct", "PurchaseOrder")', model, function (result) { //Save was successful if (result) { var createPrintOut = confirm("Do you wish to create a print out?"); if (createPrintOut) { var url = '@Url.Action("ViewPrintOut", "PurchaseOrder")'; window.location = url + "?POId=" + $("#PurchaseOrderId").val() + "&PId=" + $("#ProductId").val(); } Controller
public ActionResult ViewPrintOut(int POId, int PId) { //Make sure user has proper permissions if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders)) return AccessDeniedView(); var purchaseOrder = _purchaseOrderService.GetPurchaseOrderById(POId); string fileName = string.Format("purchaseorderproduct_{0}_{1}.pdf", PId, DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")); string filePath = System.IO.Path.Combine(this.Request.PhysicalApplicationPath, "content\\files\\ExportImport", fileName); _pdfService.PrintPurchaseOrderProductsToPdf(purchaseOrder, PId, _workContext.WorkingLanguage, filePath); var bytes = System.IO.File.ReadAllBytes(filePath); return File(bytes, "application/pdf", fileName); }