Ver código fonte

updated view PDF

master
kelvinsuen 2 meses atrás
pai
commit
90192b3d71
3 arquivos alterados com 4 adições e 3 exclusões
  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 Ver arquivo

@@ -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 Ver arquivo


src/main/resources/static/template_form.pdf → src/main/resources/templates/pdf/template_form.pdf Ver arquivo


Carregando…
Cancelar
Salvar