Show a pdf stream in a new window

后端 未结 3 542
感动是毒
感动是毒 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:53

    I couldn't do this async, but this js returns the attachment ok for me:

    $('').appendTo('body').hide();

    The browser then fires a save/view popup, which is fine for my requirements; no error handling though.

    I think with your server side, you might want to return it as inline e.g. response.setHeader("Content-Disposition", "inline; filename=file.pdf");

    You're setting the content length OK, it could be the success code will be firing twice, the first time at the beginning of the stream and the second time at the end.

    Do let us know if you got this working.

提交回复
热议问题