Show a pdf stream in a new window

后端 未结 3 532
感动是毒
感动是毒 2020-12-09 18:19

I\'m generating in a server a PDF document that I want to show then in the client. The server side looks like following:

ByteArrayOutputStream baos = generat         


        
3条回答
  •  有刺的猬
    2020-12-09 18:59

    You can get base64 string of your pdf stream and pass it to response.

    And your method change

    $.ajax({
        type: "POST",
        url: url,
        data: {"data": JSON.stringify(myData)},
        success: function(data, textStatus, jqXHR) {
            var pdfWin= window.open("data:application/pdf;base64, " + data, '', 'height=650,width=840');
            // some actions with this win, example print...
        },
        error: function(jqXHR) {
            showError("...");
        }
    });
    

提交回复
热议问题