title: How to download PDF from Spring REST service using Postman
body: <p>I have a Spring based Rest service which gives PDF as response. With my below code I can able to get the PDF content as binary values in my postman. My problem is to download it as attachment when I call the service.</p>
  
  <p>To achieve this do i need to make any change in code or in Client.</p>
  
  <pre><code>@GetMapping(value="/getUserpdf")
      public ResponseEntity&lt;Resource&gt; getUserInfo(@RequestHeader(name="reqHeader") Map&lt;String, String&gt; reqHeader,
                                                    @RequestParam(name="userId",required=true) String userId){
  
          MetaInfo metaInfo = getHeaderValues(reqHeader);
  
          //To get Actual PDF content as Bytes
          byte[] pdfBytes = getUserPdfService.getUserInfo(metaInfo,userId);
  
          ByteArrayResource resource = new ByteArrayResource(pdfBytes);
  
          HttpHeaders headers = new HttpHeaders();
          headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
          headers.add("Pragma", "no-cache");
          headers.add("Expires", "0");
          headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=UserInfo.pdf");
  
  
  
          return ResponseEntity
                        .ok()
                        .headers(headers)
                        .contentLength(pdfBytes.length)
                        .contentType(MediaType.parseMediaType("application/octet-stream")).body(resource);
      }
  </code></pre>
  
  <p>Also I have registered my Converter</p>
  
  <pre><code>@Bean
      public HttpMessageConverters customConverters() {
          ByteArrayHttpMessageConverter arrayHttpMessageConverter = new ByteArrayHttpMessageConverter();
          return new HttpMessageConverters(arrayHttpMessageConverter);
      }
  </code></pre>