Example usage for org.springframework.http MediaType APPLICATION_PDF

List of usage examples for org.springframework.http MediaType APPLICATION_PDF

Introduction

In this page you can find the example usage for org.springframework.http MediaType APPLICATION_PDF.

Prototype

MediaType APPLICATION_PDF

To view the source code for org.springframework.http MediaType APPLICATION_PDF.

Click Source Link

Document

Public constant media type for application/pdf .

Usage

From source file:de.metas.ui.web.letter.LetterRestController.java

private ResponseEntity<byte[]> createPDFResponseEntry(final byte[] pdfData) {
    final String pdfFilename = Services.get(IMsgBL.class).getMsg(Env.getCtx(), Letters.MSG_Letter);
    final HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_PDF);
    headers.set(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=\"" + pdfFilename + "\"");
    headers.setCacheControl("must-revalidate, post-check=0, pre-check=0");
    final ResponseEntity<byte[]> response = new ResponseEntity<>(pdfData, headers, HttpStatus.OK);
    return response;
}