mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-01-05 00:06:24 +01:00
cleanups formatting
This commit is contained in:
parent
0fabfea56d
commit
26af6b5636
@ -88,8 +88,6 @@ public class StampController {
|
|||||||
// Load the input PDF
|
// Load the input PDF
|
||||||
PDDocument document = Loader.loadPDF(pdfFile.getBytes());
|
PDDocument document = Loader.loadPDF(pdfFile.getBytes());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
List<Integer> pageNumbers = request.getPageNumbersList(document, false);
|
List<Integer> pageNumbers = request.getPageNumbersList(document, false);
|
||||||
|
|
||||||
for (int pageIndex : pageNumbers) {
|
for (int pageIndex : pageNumbers) {
|
||||||
|
@ -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')\"")
|
"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;
|
private String pageNumbers;
|
||||||
|
|
||||||
|
|
||||||
@Hidden
|
@Hidden
|
||||||
public List<Integer> getPageNumbersList(boolean zeroCount) {
|
public List<Integer> getPageNumbersList(boolean zeroCount) {
|
||||||
int pageCount = 0;
|
int pageCount = 0;
|
||||||
@ -38,7 +37,7 @@ public class PDFWithPageNums extends PDFFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Hidden
|
@Hidden
|
||||||
public List<Integer> getPageNumbersList(PDDocument doc,boolean zeroCount ) {
|
public List<Integer> getPageNumbersList(PDDocument doc, boolean zeroCount) {
|
||||||
int pageCount = 0;
|
int pageCount = 0;
|
||||||
pageCount = doc.getNumberOfPages();
|
pageCount = doc.getNumberOfPages();
|
||||||
return GeneralUtils.parsePageString(pageNumbers, pageCount, zeroCount);
|
return GeneralUtils.parsePageString(pageNumbers, pageCount, zeroCount);
|
||||||
|
@ -116,9 +116,11 @@ public class GeneralUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<Integer> parsePageString(String pageOrder, int totalPages) {
|
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()) {
|
if (pageOrder == null || pageOrder.isEmpty()) {
|
||||||
return Collections.singletonList(1);
|
return Collections.singletonList(1);
|
||||||
}
|
}
|
||||||
@ -128,12 +130,13 @@ public class GeneralUtils {
|
|||||||
}
|
}
|
||||||
return parsePageList(pageOrder.split(","), totalPages, isOneBased);
|
return parsePageList(pageOrder.split(","), totalPages, isOneBased);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Integer> parsePageList(String[] pageOrderArr, int totalPages) {
|
public static List<Integer> parsePageList(String[] pageOrderArr, int totalPages) {
|
||||||
return parsePageList(pageOrderArr, totalPages, false);
|
return parsePageList(pageOrderArr, totalPages, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<Integer> parsePageList(
|
||||||
public static List<Integer> parsePageList(String[] pageOrderArr, int totalPages, boolean isOneBased) {
|
String[] pageOrderArr, int totalPages, boolean isOneBased) {
|
||||||
List<Integer> newPageOrder = new ArrayList<>();
|
List<Integer> newPageOrder = new ArrayList<>();
|
||||||
|
|
||||||
int adjustmentFactor = isOneBased ? 1 : 0;
|
int adjustmentFactor = isOneBased ? 1 : 0;
|
||||||
@ -142,7 +145,7 @@ public class GeneralUtils {
|
|||||||
for (String element : pageOrderArr) {
|
for (String element : pageOrderArr) {
|
||||||
if ("all".equalsIgnoreCase(element)) {
|
if ("all".equalsIgnoreCase(element)) {
|
||||||
for (int i = 0; i < totalPages; i++) {
|
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
|
// As all pages are already added, no need to check further
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user