cleanups formatting

This commit is contained in:
Anthony Stirling 2024-02-10 14:52:59 +00:00
parent 0fabfea56d
commit 26af6b5636
3 changed files with 14 additions and 14 deletions

View file

@ -88,8 +88,6 @@ public class StampController {
// Load the input PDF
PDDocument document = Loader.loadPDF(pdfFile.getBytes());
List<Integer> pageNumbers = request.getPageNumbersList(document, false);
for (int pageIndex : pageNumbers) {

View file

@ -24,7 +24,6 @@ public class PDFWithPageNums extends PDFFile {
"The pages to select, Supports ranges (e.g., '1,3,5-9'), or 'all' or functions in the format 'an+b' where 'a' is the multiplier of the page number 'n', and 'b' is a constant (e.g., '2n+1', '3n', '6n-5')\"")
private String pageNumbers;
@Hidden
public List<Integer> getPageNumbersList(boolean zeroCount) {
int pageCount = 0;
@ -38,7 +37,7 @@ public class PDFWithPageNums extends PDFFile {
}
@Hidden
public List<Integer> getPageNumbersList(PDDocument doc,boolean zeroCount ) {
public List<Integer> getPageNumbersList(PDDocument doc, boolean zeroCount) {
int pageCount = 0;
pageCount = doc.getNumberOfPages();
return GeneralUtils.parsePageString(pageNumbers, pageCount, zeroCount);

View file

@ -116,9 +116,11 @@ public class GeneralUtils {
}
public static List<Integer> parsePageString(String pageOrder, int totalPages) {
return parsePageString(pageOrder, totalPages , false );
return parsePageString(pageOrder, totalPages, false);
}
public static List<Integer> parsePageString(String pageOrder, int totalPages, boolean isOneBased) {
public static List<Integer> parsePageString(
String pageOrder, int totalPages, boolean isOneBased) {
if (pageOrder == null || pageOrder.isEmpty()) {
return Collections.singletonList(1);
}
@ -128,12 +130,13 @@ public class GeneralUtils {
}
return parsePageList(pageOrder.split(","), totalPages, isOneBased);
}
public static List<Integer> parsePageList(String[] pageOrderArr, int totalPages) {
return parsePageList(pageOrderArr, totalPages, false);
return parsePageList(pageOrderArr, totalPages, false);
}
public static List<Integer> parsePageList(String[] pageOrderArr, int totalPages, boolean isOneBased) {
public static List<Integer> parsePageList(
String[] pageOrderArr, int totalPages, boolean isOneBased) {
List<Integer> newPageOrder = new ArrayList<>();
int adjustmentFactor = isOneBased ? 1 : 0;
@ -142,7 +145,7 @@ public class GeneralUtils {
for (String element : pageOrderArr) {
if ("all".equalsIgnoreCase(element)) {
for (int i = 0; i < totalPages; i++) {
newPageOrder.add(i+ adjustmentFactor);
newPageOrder.add(i + adjustmentFactor);
}
// As all pages are already added, no need to check further
break;