0

I'm using ASP.NET MVC and I'm using a function with AJAX that opens in the browser the window to print.

My questions is when I print I would like to already set the printer name without select the printer that I need there is any way to do that? I'm going to leave my code of my function below and a image.

function print() {
    //Serialize the form datas.   
    var printdata = $("#PrintLabel").serialize();
    
    $.ajax({
        type: "POST",
        dataType: 'HTML',
        contentType: 'application/x-www-form-urlencoded',
        url: PrintPreviewUrl,
        data: printdata,
        cache: false,
        success: function (response) {
            window.$("#printModalCenter").modal('hide');
            var WinPrint = window.open('', '', 'left=100,top=100,width=600,height=600');

            WinPrint.document.write(response);

            setTimeout(function () {
                WinPrint.print();
                WinPrint.close();

            },
                500);

        },
        fail: function () {
            WinPrint.document.close();
            WinPrint.focus();
        }
    });

This is the part that I want to prepopulate the name of the printer without having to choose and scroll down, I automatically want the name to appear when the window opens.

enter image description here

Michaelweston
  • 149
  • 1
  • 11

0 Answers0