org.apache.pdfbox.multipdf

## Class PageExtractor

- java.lang.Object
- - org.apache.pdfbox.multipdf.PageExtractor

    public class PageExtractor
    extends Object

This class will extract one or more sequential pages and create a new document.

Author:
  Adam Nichols (adam@apache.org)

### Constructor Summary

Constructors
Constructor and Description
`PageExtractor(PDDocument sourceDocument)` Creates a new instance of PageExtractor
`PageExtractor(PDDocument sourceDocument, int startPage, int endPage)` Creates a new instance of PageExtractor

### Method Summary

All Methods Instance Methods Concrete Methods
`PDDocument` `extract()` This will take a document and extract the desired pages into a new document.
`int` `getEndPage()` Gets the last page number (inclusive) to be extracted.
`int` `getStartPage()` 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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### PageExtractor

    public PageExtractor(PDDocument sourceDocument)

Creates a new instance of PageExtractor

Parameters:
  `sourceDocument` - The document to split.

#### PageExtractor

    public PageExtractor(PDDocument sourceDocument,
                         int startPage,
                         int endPage)

Creates a new instance of PageExtractor

Parameters:
  `sourceDocument` - The document to split.
  `startPage` - The first page you want extracted (1-based, inclusive)
  `endPage` - The last page you want extracted (1-based, inclusive)

### Method Detail

#### extract

    public PDDocument extract()
                       throws IOException

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