From 2fd8c643af1327f214eb70aef892e6514b0f62a3 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Sat, 22 Jul 2023 17:27:08 +0100 Subject: [PATCH] UI for html/url --- .../api/converters/ConvertHtmlToPDF.java | 2 +- .../web/ConverterWebController.java | 190 ++++++++++-------- .../templates/convert/html-to-pdf.html | 29 +++ .../templates/convert/pdf-to-html.html | 58 +++--- .../templates/convert/url-to-pdf.html | 29 +++ 5 files changed, 190 insertions(+), 118 deletions(-) create mode 100644 src/main/resources/templates/convert/html-to-pdf.html create mode 100644 src/main/resources/templates/convert/url-to-pdf.html diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java index edaf3213..d30d01dd 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java @@ -24,7 +24,7 @@ import stirling.software.SPDF.utils.WebResponseUtils; public class ConvertHtmlToPDF { - @PostMapping(consumes = "multipart/form-data", value = "/convert-to-pdf") + @PostMapping(consumes = "multipart/form-data", value = "/html-to-pdf") @Operation( summary = "Convert an HTML or ZIP (containing HTML and CSS) to PDF", description = "This endpoint takes an HTML or ZIP file input and converts it to a PDF format." diff --git a/src/main/java/stirling/software/SPDF/controller/web/ConverterWebController.java b/src/main/java/stirling/software/SPDF/controller/web/ConverterWebController.java index e8c1fa76..90429f1a 100644 --- a/src/main/java/stirling/software/SPDF/controller/web/ConverterWebController.java +++ b/src/main/java/stirling/software/SPDF/controller/web/ConverterWebController.java @@ -1,88 +1,102 @@ -package stirling.software.SPDF.controller.web; - -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.servlet.ModelAndView; - -import io.swagger.v3.oas.annotations.Hidden; -import io.swagger.v3.oas.annotations.tags.Tag; - -@Controller -@Tag(name = "Convert", description = "Convert APIs") -public class ConverterWebController { - - @GetMapping("/img-to-pdf") - @Hidden - public String convertImgToPdfForm(Model model) { - model.addAttribute("currentPage", "img-to-pdf"); - return "convert/img-to-pdf"; - } - - - @GetMapping("/pdf-to-img") - @Hidden - public String pdfToimgForm(Model model) { - model.addAttribute("currentPage", "pdf-to-img"); - return "convert/pdf-to-img"; - } - - @GetMapping("/file-to-pdf") - @Hidden - public String convertToPdfForm(Model model) { - model.addAttribute("currentPage", "file-to-pdf"); - return "convert/file-to-pdf"; - } - - - - //PDF TO...... - - @GetMapping("/pdf-to-html") - @Hidden - public ModelAndView pdfToHTML() { - ModelAndView modelAndView = new ModelAndView("convert/pdf-to-html"); - modelAndView.addObject("currentPage", "pdf-to-html"); - return modelAndView; - } - - @GetMapping("/pdf-to-presentation") - @Hidden - public ModelAndView pdfToPresentation() { - ModelAndView modelAndView = new ModelAndView("convert/pdf-to-presentation"); - modelAndView.addObject("currentPage", "pdf-to-presentation"); - return modelAndView; - } - - @GetMapping("/pdf-to-text") - @Hidden - public ModelAndView pdfToText() { - ModelAndView modelAndView = new ModelAndView("convert/pdf-to-text"); - modelAndView.addObject("currentPage", "pdf-to-text"); - return modelAndView; - } - - @GetMapping("/pdf-to-word") - @Hidden - public ModelAndView pdfToWord() { - ModelAndView modelAndView = new ModelAndView("convert/pdf-to-word"); - modelAndView.addObject("currentPage", "pdf-to-word"); - return modelAndView; - } - - @GetMapping("/pdf-to-xml") - @Hidden - public ModelAndView pdfToXML() { - ModelAndView modelAndView = new ModelAndView("convert/pdf-to-xml"); - modelAndView.addObject("currentPage", "pdf-to-xml"); - return modelAndView; - } - - - @GetMapping("/pdf-to-pdfa") - @Hidden - public String pdfToPdfAForm(Model model) { - model.addAttribute("currentPage", "pdf-to-pdfa"); - return "convert/pdf-to-pdfa"; - } -} +package stirling.software.SPDF.controller.web; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.servlet.ModelAndView; + +import io.swagger.v3.oas.annotations.Hidden; +import io.swagger.v3.oas.annotations.tags.Tag; + +@Controller +@Tag(name = "Convert", description = "Convert APIs") +public class ConverterWebController { + + @GetMapping("/img-to-pdf") + @Hidden + public String convertImgToPdfForm(Model model) { + model.addAttribute("currentPage", "img-to-pdf"); + return "convert/img-to-pdf"; + } + + @GetMapping("/html-to-pdf") + @Hidden + public String convertHTMLToPdfForm(Model model) { + model.addAttribute("currentPage", "html-to-pdf"); + return "convert/html-to-pdf"; + } + + @GetMapping("/url-to-pdf") + @Hidden + public String convertURLToPdfForm(Model model) { + model.addAttribute("currentPage", "url-to-pdf"); + return "convert/url-to-pdf"; + } + + + @GetMapping("/pdf-to-img") + @Hidden + public String pdfToimgForm(Model model) { + model.addAttribute("currentPage", "pdf-to-img"); + return "convert/pdf-to-img"; + } + + @GetMapping("/file-to-pdf") + @Hidden + public String convertToPdfForm(Model model) { + model.addAttribute("currentPage", "file-to-pdf"); + return "convert/file-to-pdf"; + } + + + + //PDF TO...... + + @GetMapping("/pdf-to-html") + @Hidden + public ModelAndView pdfToHTML() { + ModelAndView modelAndView = new ModelAndView("convert/pdf-to-html"); + modelAndView.addObject("currentPage", "pdf-to-html"); + return modelAndView; + } + + @GetMapping("/pdf-to-presentation") + @Hidden + public ModelAndView pdfToPresentation() { + ModelAndView modelAndView = new ModelAndView("convert/pdf-to-presentation"); + modelAndView.addObject("currentPage", "pdf-to-presentation"); + return modelAndView; + } + + @GetMapping("/pdf-to-text") + @Hidden + public ModelAndView pdfToText() { + ModelAndView modelAndView = new ModelAndView("convert/pdf-to-text"); + modelAndView.addObject("currentPage", "pdf-to-text"); + return modelAndView; + } + + @GetMapping("/pdf-to-word") + @Hidden + public ModelAndView pdfToWord() { + ModelAndView modelAndView = new ModelAndView("convert/pdf-to-word"); + modelAndView.addObject("currentPage", "pdf-to-word"); + return modelAndView; + } + + @GetMapping("/pdf-to-xml") + @Hidden + public ModelAndView pdfToXML() { + ModelAndView modelAndView = new ModelAndView("convert/pdf-to-xml"); + modelAndView.addObject("currentPage", "pdf-to-xml"); + return modelAndView; + } + + + @GetMapping("/pdf-to-pdfa") + @Hidden + public String pdfToPdfAForm(Model model) { + model.addAttribute("currentPage", "pdf-to-pdfa"); + return "convert/pdf-to-pdfa"; + } +} diff --git a/src/main/resources/templates/convert/html-to-pdf.html b/src/main/resources/templates/convert/html-to-pdf.html new file mode 100644 index 00000000..171a610a --- /dev/null +++ b/src/main/resources/templates/convert/html-to-pdf.html @@ -0,0 +1,29 @@ + + + + + + +
+
+
+

+
+
+
+

+
+
+
+ + +
+

+
+
+
+
+
+
+ + diff --git a/src/main/resources/templates/convert/pdf-to-html.html b/src/main/resources/templates/convert/pdf-to-html.html index a67329ac..16e0a39b 100644 --- a/src/main/resources/templates/convert/pdf-to-html.html +++ b/src/main/resources/templates/convert/pdf-to-html.html @@ -1,29 +1,29 @@ - - - - - - -
-
-
-

-
-
-
-

-
-
-
- - -
-

-
-
-
-
-
-
- - + + + + + + +
+
+
+

+
+
+
+

+
+
+
+ + +
+

+
+
+
+
+
+
+ + diff --git a/src/main/resources/templates/convert/url-to-pdf.html b/src/main/resources/templates/convert/url-to-pdf.html new file mode 100644 index 00000000..fb59b4ba --- /dev/null +++ b/src/main/resources/templates/convert/url-to-pdf.html @@ -0,0 +1,29 @@ + + + + + + +
+
+
+

+
+
+
+

+
+ +
+ + +
+

+
+
+
+
+
+
+ +