PageExtractor.java (pdfbox-2.0.23-src) | : | PageExtractor.java (pdfbox-2.0.24-src) | ||
---|---|---|---|---|
skipping to change at line 30 | skipping to change at line 30 | |||
import java.io.IOException; | import java.io.IOException; | |||
import org.apache.pdfbox.pdmodel.PDDocument; | import org.apache.pdfbox.pdmodel.PDDocument; | |||
import org.apache.pdfbox.pdmodel.PDPage; | import org.apache.pdfbox.pdmodel.PDPage; | |||
/** | /** | |||
* This class will extract one or more sequential pages and create a new documen t. | * This class will extract one or more sequential pages and create a new documen t. | |||
* @author Adam Nichols (adam@apache.org) | * @author Adam Nichols (adam@apache.org) | |||
*/ | */ | |||
public class PageExtractor | public class PageExtractor | |||
{ | { | |||
private PDDocument sourceDocument; | private final PDDocument sourceDocument; | |||
// first page to extract is page 1 (by default) | // first page to extract is page 1 (by default) | |||
private int startPage = 1; | private int startPage = 1; | |||
private int endPage = 0; | private int endPage; | |||
/** | /** | |||
* Creates a new instance of PageExtractor | * Creates a new instance of PageExtractor | |||
* @param sourceDocument The document to split. | * @param sourceDocument The document to split. | |||
*/ | */ | |||
public PageExtractor(PDDocument sourceDocument) | public PageExtractor(PDDocument sourceDocument) | |||
{ | { | |||
this.sourceDocument = sourceDocument; | this.sourceDocument = sourceDocument; | |||
endPage = sourceDocument.getNumberOfPages(); | endPage = sourceDocument.getNumberOfPages(); | |||
} | } | |||
/** | /** | |||
* Creates a new instance of PageExtractor | * Creates a new instance of PageExtractor | |||
* @param sourceDocument The document to split. | * @param sourceDocument The document to split. | |||
* @param startPage The first page you want extracted (inclusive) | * @param startPage The first page you want extracted (inclusive) | |||
* @param endPage The last page you want extracted (inclusive) | * @param endPage The last page you want extracted (inclusive) | |||
*/ | */ | |||
public PageExtractor(PDDocument sourceDocument, int startPage, int endPage) | public PageExtractor(PDDocument sourceDocument, int startPage, int endPage) | |||
{ | { | |||
this(sourceDocument); | this.sourceDocument = sourceDocument; | |||
this.startPage = startPage; | this.startPage = startPage; | |||
this.endPage = endPage; | this.endPage = endPage; | |||
} | } | |||
/** | /** | |||
* This will take a document and extract the desired pages into a new | * This will take a document and extract the desired pages into a new | |||
* document. Both startPage and endPage are included in the extracted | * document. Both startPage and endPage are included in the extracted | |||
* document. If the endPage is greater than the number of pages in the | * document. If the endPage is greater than the number of pages in the | |||
* source document, it will go to the end of the document. If startPage is | * source document, it will go to the end of the document. If startPage is | |||
* less than 1, it'll start with page 1. If startPage is greater than | * less than 1, it'll start with page 1. If startPage is greater than | |||
End of changes. 3 change blocks. | ||||
3 lines changed or deleted | 3 lines changed or added |