cleanups formatting
This commit is contained in:
parent
0fabfea56d
commit
26af6b5636
3 changed files with 14 additions and 14 deletions
|
@ -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) {
|
||||
|
@ -319,4 +317,4 @@ public class StampController {
|
|||
private float calculateTextCapHeight(PDFont font, float fontSize) {
|
||||
return font.getFontDescriptor().getCapHeight() / 1000 * fontSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -36,9 +35,9 @@ public class PDFWithPageNums extends PDFFile {
|
|||
}
|
||||
return GeneralUtils.parsePageString(pageNumbers, pageCount, zeroCount);
|
||||
}
|
||||
|
||||
|
||||
@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);
|
||||
|
|
|
@ -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,21 +130,22 @@ 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;
|
||||
|
||||
|
||||
// loop through the page order array
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue