Good day, I'm working rotativa
to generate a pdf, which doesn't give me a problem. I've been investigating a way to print the pdf directly without showing the pdf preview in the browser for a while, but it seems there is no possible way. so instead I'm looking to see if there's a way that opening the pdf in the window will also open the print window. the system will be used only in google chrome, so i need to make it compatible with it. I currently generate the PDF as follows:
public Rotativa.MVC.ActionAsPdf HojaPedidoSimple(string selectedProvider, string sucursal)
{
return new Rotativa.MVC.ActionAsPdf("HojaPedido", new { selectedProvider = selectedProvider,sucursal=sucursal,pdf = true });
}
How I call that PDF with javascript:
url = "@Html.Raw(Url.Action("PrintHojaPedido",new {@selectedProvider="4a5b6c",@sucursal="1a2b3c" }))";
url = url.replace("1a2b3c", SelectedSucursal);
url = url.replace("4a5b6c", selectedProvider);
var win = window.open(url, '_blank');
win.focus();
Is it possible to do what I want? I haven't found anything about it on the internet.
You can open the option to print a browser window with the function
window.print()
and if you save in a variable the execution ofwindow.open()
you can use the methodprint()
in that variable.I would put it before
win.focus();
JavaScript