Set filename of the Pdf that is streamed back to the browser

后端 未结 6 1040
太阳男子
太阳男子 2021-02-06 03:01

I have a Java webapp creating a pdf and streaming it back to the browser.

 byte[] pdf = report.exportPdfToArray(user);
response.setContentType(\"application/pdf         


        
6条回答
  •  無奈伤痛
    2021-02-06 03:04

    I have tried a solution in java and it worked.

    response.setHeader("Content-Disposition","inline; filename=\"MyFile.pdf\"");
    response.setContentType("application/pdf; name=\"MyFile.pdf\"");
    response.getOutputStream().write(pdfAsBytesArray);
    

提交回复
热议问题