slow rework testing, still on multipage
This commit is contained in:
parent
24e665bfd5
commit
2c0fb33548
8 changed files with 29 additions and 27 deletions
|
@ -180,8 +180,6 @@ public class RearrangePagesPDFController {
|
||||||
// Split the page order string into an array of page numbers or range of numbers
|
// Split the page order string into an array of page numbers or range of numbers
|
||||||
String[] pageOrderArr = pageOrder != null ? pageOrder.split(",") : new String[0];
|
String[] pageOrderArr = pageOrder != null ? pageOrder.split(",") : new String[0];
|
||||||
int totalPages = document.getNumberOfPages();
|
int totalPages = document.getNumberOfPages();
|
||||||
System.out.println("pageOrder=" + pageOrder);
|
|
||||||
System.out.println("SortTypes length =" + sortType.length());
|
|
||||||
List<Integer> newPageOrder;
|
List<Integer> newPageOrder;
|
||||||
if (sortType != null && sortType.length() > 0) {
|
if (sortType != null && sortType.length() > 0) {
|
||||||
newPageOrder = processSortTypes(sortType, totalPages);
|
newPageOrder = processSortTypes(sortType, totalPages);
|
||||||
|
|
|
@ -46,6 +46,8 @@ public class SplitPDFController {
|
||||||
PDDocument document = PDDocument.load(inputStream);
|
PDDocument document = PDDocument.load(inputStream);
|
||||||
|
|
||||||
List<Integer> pageNumbers = request.getPageNumbersList(document);
|
List<Integer> pageNumbers = request.getPageNumbersList(document);
|
||||||
|
if(!pageNumbers.contains(document.getNumberOfPages() - 1))
|
||||||
|
pageNumbers.add(document.getNumberOfPages()- 1);
|
||||||
logger.info("Splitting PDF into pages: {}", pageNumbers.stream().map(String::valueOf).collect(Collectors.joining(",")));
|
logger.info("Splitting PDF into pages: {}", pageNumbers.stream().map(String::valueOf).collect(Collectors.joining(",")));
|
||||||
|
|
||||||
// split the document
|
// split the document
|
||||||
|
|
|
@ -140,6 +140,15 @@ public class GeneralWebController {
|
||||||
return "sign";
|
return "sign";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/multi-page-layout")
|
||||||
|
@Hidden
|
||||||
|
public String multiPageLayoutForm(Model model) {
|
||||||
|
model.addAttribute("currentPage", "multi-page-layout");
|
||||||
|
return "multi-page-layout";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ResourceLoader resourceLoader;
|
private ResourceLoader resourceLoader;
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class OtherWebController {
|
||||||
@Hidden
|
@Hidden
|
||||||
public String compressPdfForm(Model model) {
|
public String compressPdfForm(Model model) {
|
||||||
model.addAttribute("currentPage", "compress-pdf");
|
model.addAttribute("currentPage", "compress-pdf");
|
||||||
return "other/compress-pdf";
|
return "misc/compress-pdf";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/extract-image-scans")
|
@GetMapping("/extract-image-scans")
|
||||||
|
@ -36,7 +36,7 @@ public class OtherWebController {
|
||||||
@Hidden
|
@Hidden
|
||||||
public String extractJavascriptForm(Model model) {
|
public String extractJavascriptForm(Model model) {
|
||||||
model.addAttribute("currentPage", "show-javascript");
|
model.addAttribute("currentPage", "show-javascript");
|
||||||
return "other/show-javascript";
|
return "misc/show-javascript";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,21 +44,21 @@ public class OtherWebController {
|
||||||
@Hidden
|
@Hidden
|
||||||
public String addPageNumbersForm(Model model) {
|
public String addPageNumbersForm(Model model) {
|
||||||
model.addAttribute("currentPage", "add-page-numbers");
|
model.addAttribute("currentPage", "add-page-numbers");
|
||||||
return "other/add-page-numbers";
|
return "misc/add-page-numbers";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/extract-images")
|
@GetMapping("/extract-images")
|
||||||
@Hidden
|
@Hidden
|
||||||
public String extractImagesForm(Model model) {
|
public String extractImagesForm(Model model) {
|
||||||
model.addAttribute("currentPage", "extract-images");
|
model.addAttribute("currentPage", "extract-images");
|
||||||
return "other/extract-images";
|
return "misc/extract-images";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/flatten")
|
@GetMapping("/flatten")
|
||||||
@Hidden
|
@Hidden
|
||||||
public String flattenForm(Model model) {
|
public String flattenForm(Model model) {
|
||||||
model.addAttribute("currentPage", "flatten");
|
model.addAttribute("currentPage", "flatten");
|
||||||
return "other/flatten";
|
return "misc/flatten";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,14 +67,14 @@ public class OtherWebController {
|
||||||
@Hidden
|
@Hidden
|
||||||
public String addWatermarkForm(Model model) {
|
public String addWatermarkForm(Model model) {
|
||||||
model.addAttribute("currentPage", "change-metadata");
|
model.addAttribute("currentPage", "change-metadata");
|
||||||
return "other/change-metadata";
|
return "misc/change-metadata";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/compare")
|
@GetMapping("/compare")
|
||||||
@Hidden
|
@Hidden
|
||||||
public String compareForm(Model model) {
|
public String compareForm(Model model) {
|
||||||
model.addAttribute("currentPage", "compare");
|
model.addAttribute("currentPage", "compare");
|
||||||
return "other/compare";
|
return "misc/compare";
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getAvailableTesseractLanguages() {
|
public List<String> getAvailableTesseractLanguages() {
|
||||||
|
@ -103,56 +103,49 @@ public class OtherWebController {
|
||||||
@Hidden
|
@Hidden
|
||||||
public String overlayImage(Model model) {
|
public String overlayImage(Model model) {
|
||||||
model.addAttribute("currentPage", "add-image");
|
model.addAttribute("currentPage", "add-image");
|
||||||
return "other/add-image";
|
return "misc/add-image";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/adjust-contrast")
|
@GetMapping("/adjust-contrast")
|
||||||
@Hidden
|
@Hidden
|
||||||
public String contrast(Model model) {
|
public String contrast(Model model) {
|
||||||
model.addAttribute("currentPage", "adjust-contrast");
|
model.addAttribute("currentPage", "adjust-contrast");
|
||||||
return "other/adjust-contrast";
|
return "misc/adjust-contrast";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/repair")
|
@GetMapping("/repair")
|
||||||
@Hidden
|
@Hidden
|
||||||
public String repairForm(Model model) {
|
public String repairForm(Model model) {
|
||||||
model.addAttribute("currentPage", "repair");
|
model.addAttribute("currentPage", "repair");
|
||||||
return "other/repair";
|
return "misc/repair";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/remove-blanks")
|
@GetMapping("/remove-blanks")
|
||||||
@Hidden
|
@Hidden
|
||||||
public String removeBlanksForm(Model model) {
|
public String removeBlanksForm(Model model) {
|
||||||
model.addAttribute("currentPage", "remove-blanks");
|
model.addAttribute("currentPage", "remove-blanks");
|
||||||
return "other/remove-blanks";
|
return "misc/remove-blanks";
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/multi-page-layout")
|
|
||||||
@Hidden
|
|
||||||
public String multiPageLayoutForm(Model model) {
|
|
||||||
model.addAttribute("currentPage", "multi-page-layout");
|
|
||||||
return "other/multi-page-layout";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/scale-pages")
|
@GetMapping("/scale-pages")
|
||||||
@Hidden
|
@Hidden
|
||||||
public String scalePagesFrom(Model model) {
|
public String scalePagesFrom(Model model) {
|
||||||
model.addAttribute("currentPage", "scale-pages");
|
model.addAttribute("currentPage", "scale-pages");
|
||||||
return "other/scale-pages";
|
return "misc/scale-pages";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/auto-crop")
|
@GetMapping("/auto-crop")
|
||||||
@Hidden
|
@Hidden
|
||||||
public String autoCropForm(Model model) {
|
public String autoCropForm(Model model) {
|
||||||
model.addAttribute("currentPage", "auto-crop");
|
model.addAttribute("currentPage", "auto-crop");
|
||||||
return "other/auto-crop";
|
return "misc/auto-crop";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/auto-rename")
|
@GetMapping("/auto-rename")
|
||||||
@Hidden
|
@Hidden
|
||||||
public String autoRenameForm(Model model) {
|
public String autoRenameForm(Model model) {
|
||||||
model.addAttribute("currentPage", "auto-rename");
|
model.addAttribute("currentPage", "auto-rename");
|
||||||
return "other/auto-rename";
|
return "misc/auto-rename";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class GeneralUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Integer> parsePageString(String pageOrder, int totalPages) {
|
public static List<Integer> parsePageString(String pageOrder, int totalPages) {
|
||||||
return parsePageList(pageOrder.split(","), 100);
|
return parsePageList(pageOrder.split(","), totalPages);
|
||||||
}
|
}
|
||||||
public static List<Integer> parsePageList(String[] pageOrderArr, int totalPages) {
|
public static List<Integer> parsePageList(String[] pageOrderArr, int totalPages) {
|
||||||
List<Integer> newPageOrder = new ArrayList<>();
|
List<Integer> newPageOrder = new ArrayList<>();
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<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="#{pageLayout.header}"></h2>
|
<h2 th:text="#{pageLayout.header}"></h2>
|
||||||
<form id="multiPdfForm" th:action="@{api/v1/misc/multi-page-layout}" method="post" enctype="multipart/form-data">
|
<form id="multiPdfForm" th:action="@{api/v1/general/multi-page-layout}" method="post" enctype="multipart/form-data">
|
||||||
<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>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="pagesPerSheet" th:text="#{pageLayout.pagesPerSheet}"></label>
|
<label for="pagesPerSheet" th:text="#{pageLayout.pagesPerSheet}"></label>
|
|
@ -32,7 +32,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="pageOrder" th:text="#{pageOrderPrompt}"></label>
|
<label for="pageOrder" th:text="#{pageOrderPrompt}"></label>
|
||||||
<input type="text" class="form-control" id="pageOrder" name="pageOrder" placeholder="(e.g. 1,3,2 or 4-8,2,10-12 or 2n-1)" required>
|
<input type="text" class="form-control" id="pageOrder" name="pageNumbers" placeholder="(e.g. 1,3,2 or 4-8,2,10-12 or 2n-1)" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{pdfOrganiser.submit}"></button>
|
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{pdfOrganiser.submit}"></button>
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="pages" th:text="#{split.splitPages}"></label>
|
<label for="pages" th:text="#{split.splitPages}"></label>
|
||||||
<input type="text" class="form-control" id="pages" name="pages" placeholder="1,3,5-10" required>
|
<input type="text" class="form-control" id="pageNumbers" name="pageNumbers" placeholder="1,3,5-10" required>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{split.submit}"></button>
|
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{split.submit}"></button>
|
||||||
|
|
Loading…
Reference in a new issue