Guest User

Untitled

a guest
Mar 14th, 2018
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. public ResponseEntity<byte []> getInfo(
  2. @PathVariable("id") String distributorId, @PathVariable("country")
  3. String country) throws JSONException, IOException,
  4. URISyntaxException, ParseException, DocumentException {
  5. logger.trace(START);
  6. ByteArrayOutputStream myDetails =
  7. enrollmentService.getInfo(id,country);
  8. HttpHeaders headers = new HttpHeaders();
  9. headers.setContentType(MediaType.parseMediaType("application/pdf"));
  10. String filename = "output.pdf";
  11. headers.setContentDispositionFormData(filename, filename);
  12. headers.setCacheControl("must-revalidate, post-check=0, pre-check=0");
  13. byte[] sos=myDetails.toByteArray();
  14. return new ResponseEntity<>(sos,headers, sos == null ?
  15. HttpStatus.NO_CONTENT : HttpStatus.OK );
  16. }
  17.  
  18. getInfo(distributorId: string,
  19. country:string,month:number,year:number): Observable<any> {
  20. let url='Some sample url';
  21.  
  22. return this._http.
  23. get(url, { responseType: ResponseContentType.ArrayBuffer })
  24. .map((response: Response) => response.arrayBuffer())
  25. .map((arrayBuffer: ArrayBuffer) => new Uint8Array(arrayBuffer))
  26. .catch(this.handleErrorObservable);
  27. }
  28.  
  29. RangeError: byte length of Uint16Array should be a multiple of 2
  30. at new Uint16Array (native)
Add Comment
Please, Sign In to add comment