title: SpringBoot - display PDF-file in browser instead of downloading
body: <p>i am trying to display a pdf in my browser with spring. my problem is that the browser downloads the file instead of displaying it. this is my code:</p>
  
  <pre><code> @RequestMapping(value = "/download" , method=RequestMethod.GET , produces = "application/pdf")
  public ResponseEntity&lt;InputStreamResource&gt; downloadPdf() throws IOException {
      ClassPathResource pdfFile = new ClassPathResource("TMOBILE.pdf");
      return ResponseEntity
              .ok()
              .contentLength(pdfFile.contentLength())
              .contentType(
                      MediaType.parseMediaType("application/octet-stream"))
              .body(new InputStreamResource(pdfFile.getInputStream()));
  
  }
  </code></pre>
  
  <p>i am looking forward to your answers! thanks</p>