瀏覽代碼

updated view PDF

master
kelvinsuen 2 月之前
父節點
當前提交
90192b3d71
共有 3 個檔案被更改,包括 4 行新增3 行删除
  1. +4
    -3
      src/main/java/com/ffii/lioner/modules/lioner/web/PdfController.java
  2. +0
    -0
      src/main/resources/templates/pdf/HSBC B24102883_fillable_Financial Needs Analysis for Individual Nov2024.pdf
  3. +0
    -0
      src/main/resources/templates/pdf/template_form.pdf

+ 4
- 3
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<byte[]> 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<Map<String, String>> saveFilledPdf(@RequestParam("file") MultipartFile file) {
if (file.isEmpty()) {
return ResponseEntity.badRequest().body(Map.of("message", "No file uploaded."));


src/main/resources/static/HSBC B24102883_fillable_Financial Needs Analysis for Individual Nov2024.pdf → src/main/resources/templates/pdf/HSBC B24102883_fillable_Financial Needs Analysis for Individual Nov2024.pdf 查看文件


src/main/resources/static/template_form.pdf → src/main/resources/templates/pdf/template_form.pdf 查看文件


Loading…
取消
儲存