From 90192b3d71e731c09c7285112e072dbab248c111 Mon Sep 17 00:00:00 2001 From: kelvinsuen Date: Thu, 26 Jun 2025 11:18:49 +0800 Subject: [PATCH] updated view PDF --- .../lioner/modules/lioner/web/PdfController.java | 7 ++++--- ...ancial Needs Analysis for Individual Nov2024.pdf | Bin .../{static => templates/pdf}/template_form.pdf | Bin 3 files changed, 4 insertions(+), 3 deletions(-) rename src/main/resources/{static => templates/pdf}/HSBC B24102883_fillable_Financial Needs Analysis for Individual Nov2024.pdf (100%) rename src/main/resources/{static => templates/pdf}/template_form.pdf (100%) diff --git a/src/main/java/com/ffii/lioner/modules/lioner/web/PdfController.java b/src/main/java/com/ffii/lioner/modules/lioner/web/PdfController.java index 5dd2c3b..c6b8d4c 100644 --- a/src/main/java/com/ffii/lioner/modules/lioner/web/PdfController.java +++ b/src/main/java/com/ffii/lioner/modules/lioner/web/PdfController.java @@ -28,12 +28,14 @@ import org.springframework.web.multipart.MultipartFile; @CrossOrigin(origins = "", allowedHeaders = "") public class PdfController { + + private String pdf_path = "templates/pdf/"; // Endpoint to serve the initial template PDF @GetMapping(value = "/template", produces = MediaType.APPLICATION_PDF_VALUE) public ResponseEntity getPdfTemplate() throws IOException { // Ensure your template PDF is in src/main/resources/static/ - ClassPathResource pdfFile = new ClassPathResource("static/template_form.pdf"); + ClassPathResource pdfFile = new ClassPathResource(pdf_path + "HSBC B24102883_fillable_Financial Needs Analysis for Individual Nov2024.pdf"); if (!pdfFile.exists()) { return ResponseEntity.status(HttpStatus.NOT_FOUND).body("PDF template not found.".getBytes()); } @@ -45,12 +47,11 @@ public class PdfController { HttpHeaders headers = new HttpHeaders(); headers.setContentDispositionFormData("inline", "template_form.pdf"); headers.setContentType(MediaType.APPLICATION_PDF); - System.out.println("chk+ " + pdfBytes); return new ResponseEntity<>(pdfBytes, headers, HttpStatus.OK); } // Endpoint to receive the filled PDF from the frontend - @PostMapping(value = "/saveFilled", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + @PostMapping(value = "/save", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public ResponseEntity> saveFilledPdf(@RequestParam("file") MultipartFile file) { if (file.isEmpty()) { return ResponseEntity.badRequest().body(Map.of("message", "No file uploaded.")); diff --git a/src/main/resources/static/HSBC B24102883_fillable_Financial Needs Analysis for Individual Nov2024.pdf b/src/main/resources/templates/pdf/HSBC B24102883_fillable_Financial Needs Analysis for Individual Nov2024.pdf similarity index 100% rename from src/main/resources/static/HSBC B24102883_fillable_Financial Needs Analysis for Individual Nov2024.pdf rename to src/main/resources/templates/pdf/HSBC B24102883_fillable_Financial Needs Analysis for Individual Nov2024.pdf diff --git a/src/main/resources/static/template_form.pdf b/src/main/resources/templates/pdf/template_form.pdf similarity index 100% rename from src/main/resources/static/template_form.pdf rename to src/main/resources/templates/pdf/template_form.pdf