UI for html/url

This commit is contained in:
Anthony Stirling 2023-07-22 17:27:08 +01:00
parent 4367ae7934
commit 2fd8c643af
5 changed files with 190 additions and 118 deletions

View File

@ -24,7 +24,7 @@ import stirling.software.SPDF.utils.WebResponseUtils;
public class ConvertHtmlToPDF { public class ConvertHtmlToPDF {
@PostMapping(consumes = "multipart/form-data", value = "/convert-to-pdf") @PostMapping(consumes = "multipart/form-data", value = "/html-to-pdf")
@Operation( @Operation(
summary = "Convert an HTML or ZIP (containing HTML and CSS) to PDF", 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." description = "This endpoint takes an HTML or ZIP file input and converts it to a PDF format."

View File

@ -1,88 +1,102 @@
package stirling.software.SPDF.controller.web; package stirling.software.SPDF.controller.web;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@Controller @Controller
@Tag(name = "Convert", description = "Convert APIs") @Tag(name = "Convert", description = "Convert APIs")
public class ConverterWebController { public class ConverterWebController {
@GetMapping("/img-to-pdf") @GetMapping("/img-to-pdf")
@Hidden @Hidden
public String convertImgToPdfForm(Model model) { public String convertImgToPdfForm(Model model) {
model.addAttribute("currentPage", "img-to-pdf"); model.addAttribute("currentPage", "img-to-pdf");
return "convert/img-to-pdf"; return "convert/img-to-pdf";
} }
@GetMapping("/html-to-pdf")
@GetMapping("/pdf-to-img") @Hidden
@Hidden public String convertHTMLToPdfForm(Model model) {
public String pdfToimgForm(Model model) { model.addAttribute("currentPage", "html-to-pdf");
model.addAttribute("currentPage", "pdf-to-img"); return "convert/html-to-pdf";
return "convert/pdf-to-img"; }
}
@GetMapping("/url-to-pdf")
@GetMapping("/file-to-pdf") @Hidden
@Hidden public String convertURLToPdfForm(Model model) {
public String convertToPdfForm(Model model) { model.addAttribute("currentPage", "url-to-pdf");
model.addAttribute("currentPage", "file-to-pdf"); return "convert/url-to-pdf";
return "convert/file-to-pdf"; }
}
@GetMapping("/pdf-to-img")
@Hidden
//PDF TO...... public String pdfToimgForm(Model model) {
model.addAttribute("currentPage", "pdf-to-img");
@GetMapping("/pdf-to-html") return "convert/pdf-to-img";
@Hidden }
public ModelAndView pdfToHTML() {
ModelAndView modelAndView = new ModelAndView("convert/pdf-to-html"); @GetMapping("/file-to-pdf")
modelAndView.addObject("currentPage", "pdf-to-html"); @Hidden
return modelAndView; public String convertToPdfForm(Model model) {
} model.addAttribute("currentPage", "file-to-pdf");
return "convert/file-to-pdf";
@GetMapping("/pdf-to-presentation") }
@Hidden
public ModelAndView pdfToPresentation() {
ModelAndView modelAndView = new ModelAndView("convert/pdf-to-presentation");
modelAndView.addObject("currentPage", "pdf-to-presentation"); //PDF TO......
return modelAndView;
} @GetMapping("/pdf-to-html")
@Hidden
@GetMapping("/pdf-to-text") public ModelAndView pdfToHTML() {
@Hidden ModelAndView modelAndView = new ModelAndView("convert/pdf-to-html");
public ModelAndView pdfToText() { modelAndView.addObject("currentPage", "pdf-to-html");
ModelAndView modelAndView = new ModelAndView("convert/pdf-to-text"); return modelAndView;
modelAndView.addObject("currentPage", "pdf-to-text"); }
return modelAndView;
} @GetMapping("/pdf-to-presentation")
@Hidden
@GetMapping("/pdf-to-word") public ModelAndView pdfToPresentation() {
@Hidden ModelAndView modelAndView = new ModelAndView("convert/pdf-to-presentation");
public ModelAndView pdfToWord() { modelAndView.addObject("currentPage", "pdf-to-presentation");
ModelAndView modelAndView = new ModelAndView("convert/pdf-to-word"); return modelAndView;
modelAndView.addObject("currentPage", "pdf-to-word"); }
return modelAndView;
} @GetMapping("/pdf-to-text")
@Hidden
@GetMapping("/pdf-to-xml") public ModelAndView pdfToText() {
@Hidden ModelAndView modelAndView = new ModelAndView("convert/pdf-to-text");
public ModelAndView pdfToXML() { modelAndView.addObject("currentPage", "pdf-to-text");
ModelAndView modelAndView = new ModelAndView("convert/pdf-to-xml"); return modelAndView;
modelAndView.addObject("currentPage", "pdf-to-xml"); }
return modelAndView;
} @GetMapping("/pdf-to-word")
@Hidden
public ModelAndView pdfToWord() {
@GetMapping("/pdf-to-pdfa") ModelAndView modelAndView = new ModelAndView("convert/pdf-to-word");
@Hidden modelAndView.addObject("currentPage", "pdf-to-word");
public String pdfToPdfAForm(Model model) { return modelAndView;
model.addAttribute("currentPage", "pdf-to-pdfa"); }
return "convert/pdf-to-pdfa";
} @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";
}
}

View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html th:lang="${#locale.toString()}" th:lang-direction="#{language.direction}" xmlns:th="http://www.thymeleaf.org">
<th:block th:insert="~{fragments/common :: head(title=#{HTMLToPDF.title})}"></th:block>
<body>
<th:block th:insert="~{fragments/common :: game}"></th:block>
<div id="page-container">
<div id="content-wrap">
<div th:insert="~{fragments/navbar.html :: navbar}"></div>
<br> <br>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-6">
<h2 th:text="#{HTMLToPDF.header}"></h2>
<form method="post" enctype="multipart/form-data" th:action="@{html-to-pdf}">
<div th:replace="~{fragments/common :: fileSelector(name='fileInput', multiple=false)}"></div>
<br>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{HTMLToPDF.submit}"></button>
</form>
<p class="mt-3" th:text="#{HTMLToPDF.credit}"></p>
</div>
</div>
</div>
</div>
<div th:insert="~{fragments/footer.html :: footer}"></div>
</div>
</body>
</html>

View File

@ -1,29 +1,29 @@
<!DOCTYPE html> <!DOCTYPE html>
<html th:lang="${#locale.toString()}" th:lang-direction="#{language.direction}" xmlns:th="http://www.thymeleaf.org"> <html th:lang="${#locale.toString()}" th:lang-direction="#{language.direction}" xmlns:th="http://www.thymeleaf.org">
<th:block th:insert="~{fragments/common :: head(title=#{PDFToHTML.title})}"></th:block> <th:block th:insert="~{fragments/common :: head(title=#{HTMLToPDF.title})}"></th:block>
<body> <body>
<th:block th:insert="~{fragments/common :: game}"></th:block> <th:block th:insert="~{fragments/common :: game}"></th:block>
<div id="page-container"> <div id="page-container">
<div id="content-wrap"> <div id="content-wrap">
<div th:insert="~{fragments/navbar.html :: navbar}"></div> <div th:insert="~{fragments/navbar.html :: navbar}"></div>
<br> <br> <br> <br>
<div class="container"> <div class="container">
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col-md-6"> <div class="col-md-6">
<h2 th:text="#{PDFToHTML.header}"></h2> <h2 th:text="#{HTMLToPDF.header}"></h2>
<form method="post" enctype="multipart/form-data" th:action="@{pdf-to-html}"> <form method="post" enctype="multipart/form-data" th:action="@{html-to-pdf}">
<div th:replace="~{fragments/common :: fileSelector(name='fileInput', multiple=false, accept='application/pdf')}"></div> <div th:replace="~{fragments/common :: fileSelector(name='fileInput', multiple=false, accept='application/pdf')}"></div>
<br> <br>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{PDFToHTML.submit}"></button> <button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{HTMLToPDF.submit}"></button>
</form> </form>
<p class="mt-3" th:text="#{PDFToHTML.credit}"></p> <p class="mt-3" th:text="#{HTMLToPDF.credit}"></p>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div th:insert="~{fragments/footer.html :: footer}"></div> <div th:insert="~{fragments/footer.html :: footer}"></div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html th:lang="${#locale.toString()}" th:lang-direction="#{language.direction}" xmlns:th="http://www.thymeleaf.org">
<th:block th:insert="~{fragments/common :: head(title=#{URLToPDF.title})}"></th:block>
<body>
<th:block th:insert="~{fragments/common :: game}"></th:block>
<div id="page-container">
<div id="content-wrap">
<div th:insert="~{fragments/navbar.html :: navbar}"></div>
<br> <br>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-6">
<h2 th:text="#{URLToPDF.header}"></h2>
<form method="post" enctype="multipart/form-data" th:action="@{url-to-pdf}">
<input type="text" class="form-control" id="urlInput" name="urlInput">
<br>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{URLToPDF.submit}"></button>
</form>
<p class="mt-3" th:text="#{URLToPDF.credit}"></p>
</div>
</div>
</div>
</div>
<div th:insert="~{fragments/footer.html :: footer}"></div>
</div>
</body>
</html>