Package org.apache.pdfbox.util
Class PageExtractor
java.lang.Object
org.apache.pdfbox.util.PageExtractor
This class will extract one or more sequential pages and create a new document.
- Author:
- Adam Nichols (adam@apache.org)
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPageExtractor
(PDDocument sourceDocument) Creates a new instance of PageExtractorPageExtractor
(PDDocument sourceDocument, int startPage, int endPage) Creates a new instance of PageExtractor -
Method Summary
Modifier and TypeMethodDescriptionextract()
This will take a document and extract the desired pages into a new document.int
Gets the last page number (inclusive) to be extracted.int
Gets the first page number to be extracted.void
setEndPage
(int endPage) Sets the last page number to be extracted.void
setStartPage
(int startPage) Sets the first page number to be extracted.
-
Field Details
-
sourceDocument
-
startPage
protected int startPage -
endPage
protected int endPage
-
-
Constructor Details
-
PageExtractor
Creates a new instance of PageExtractor- Parameters:
sourceDocument
- The document to split.
-
PageExtractor
Creates a new instance of PageExtractor- Parameters:
sourceDocument
- The document to split.startPage
- The first page you want extracted (inclusive)endPage
- The last page you want extracted (inclusive)
-
-
Method Details
-
extract
This will take a document and extract the desired pages into a new document. Both startPage and endPage are included in the extracted 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 less than 1, it'll start with page 1. If startPage is greater than endPage or greater than the number of pages in the source document, a blank document will be returned.- Returns:
- The extracted document
- Throws:
IOException
- If there is an IOError
-
getStartPage
public int getStartPage()Gets the first page number to be extracted.- Returns:
- the first page number which should be extracted
-
setStartPage
public void setStartPage(int startPage) Sets the first page number to be extracted.- Parameters:
startPage
- the first page number which should be extracted
-
getEndPage
public int getEndPage()Gets the last page number (inclusive) to be extracted.- Returns:
- the last page number which should be extracted
-
setEndPage
public void setEndPage(int endPage) Sets the last page number to be extracted.- Parameters:
endPage
- the last page number which should be extracted
-