mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2024-06-02 22:00:13 +02:00
1e4134c7d1
* init * user and pass to just pass lang update * session management fixes and avoid demo user locking * fix for UMASK and extract cleanups * fixes for user #889 and #332 * increase session count for demo site * fix * gcc * formatting * number fixes init * || true test * version bump * Hardening suggestions for Stirling-PDF / numberFxes (#899) Switch order of literals to prevent NullPointerException Co-authored-by: pixeebot[bot] <104101892+pixeebot[bot]@users.noreply.github.com> --------- Co-authored-by: pixeebot[bot] <104101892+pixeebot[bot]@users.noreply.github.com>
46 lines
1.4 KiB
Java
46 lines
1.4 KiB
Java
package stirling.software.SPDF.model.api;
|
|
|
|
import java.io.IOException;
|
|
import java.util.List;
|
|
|
|
import org.apache.pdfbox.Loader;
|
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
|
|
|
import io.swagger.v3.oas.annotations.Hidden;
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
|
|
import lombok.Data;
|
|
import lombok.EqualsAndHashCode;
|
|
import lombok.NoArgsConstructor;
|
|
import stirling.software.SPDF.utils.GeneralUtils;
|
|
|
|
@Data
|
|
@NoArgsConstructor
|
|
@EqualsAndHashCode(callSuper = true)
|
|
public class PDFWithPageNums extends PDFFile {
|
|
|
|
@Schema(
|
|
description =
|
|
"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;
|
|
try {
|
|
pageCount = Loader.loadPDF(getFileInput().getBytes()).getNumberOfPages();
|
|
} catch (IOException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
return GeneralUtils.parsePageList(pageNumbers, pageCount, zeroCount);
|
|
}
|
|
|
|
@Hidden
|
|
public List<Integer> getPageNumbersList(PDDocument doc, boolean zeroCount) {
|
|
int pageCount = 0;
|
|
pageCount = doc.getNumberOfPages();
|
|
return GeneralUtils.parsePageList(pageNumbers, pageCount, zeroCount);
|
|
}
|
|
}
|