From 624e0e3619ee44942b2fbf44a78cd5500aedff33 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Sun, 29 Jan 2023 17:13:47 +0000 Subject: [PATCH] Delete FromPDFController.java --- .../SPDF/controller/FromPDFController.java | 48 ------------------- 1 file changed, 48 deletions(-) delete mode 100644 src/main/java/stirling/software/SPDF/controller/FromPDFController.java diff --git a/src/main/java/stirling/software/SPDF/controller/FromPDFController.java b/src/main/java/stirling/software/SPDF/controller/FromPDFController.java deleted file mode 100644 index 00c33616..00000000 --- a/src/main/java/stirling/software/SPDF/controller/FromPDFController.java +++ /dev/null @@ -1,48 +0,0 @@ -package stirling.software.SPDF.controller; - -import java.io.IOException; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; - -import stirling.software.SPDF.utils.PdfUtils; - -@Controller -public class FromPDFController { - - private static final Logger logger = LoggerFactory.getLogger(FromPDFController.class); - - - @PostMapping("/convert-from-pdf") - public ResponseEntity convertToImage(@RequestParam("fileInput") MultipartFile file, - @RequestParam("imageFormat") String imageFormat) throws IOException { - byte[] pdfBytes = file.getBytes(); - //returns bytes for image - byte[] result = PdfUtils.convertFromPdf(pdfBytes, imageFormat.toLowerCase()); - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.parseMediaType(getMediaType(imageFormat))); - headers.setCacheControl("must-revalidate, post-check=0, pre-check=0"); - ResponseEntity response = new ResponseEntity<>(result, headers, HttpStatus.OK); - return response; - } - - private String getMediaType(String imageFormat) { - if(imageFormat.equalsIgnoreCase("PNG")) - return "image/png"; - else if(imageFormat.equalsIgnoreCase("JPEG") || imageFormat.equalsIgnoreCase("JPG")) - return "image/jpeg"; - else if(imageFormat.equalsIgnoreCase("GIF")) - return "image/gif"; - else - return "application/octet-stream"; - } -}