org.apache.pdfbox.util
Class PageExtractor

java.lang.Object
  extended by org.apache.pdfbox.util.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)

Field Summary
protected  int endPage
           
protected  PDDocument sourceDocument
           
protected  int startPage
           
 
Constructor Summary
PageExtractor(PDDocument sourceDocument)
          Creates a new instance of PageExtractor
PageExtractor(PDDocument sourceDocument, int startPage, int endPage)
          Creates a new instance of PageExtractor
 
Method Summary
 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
 

Field Detail

sourceDocument

protected PDDocument sourceDocument

startPage

protected int startPage

endPage

protected int endPage
Constructor Detail

PageExtractor

public PageExtractor(PDDocument sourceDocument)
Creates a new instance of PageExtractor

Parameters:
document - The document to split.

PageExtractor

public PageExtractor(PDDocument sourceDocument,
                     int startPage,
                     int endPage)
Creates a new instance of PageExtractor

Parameters:
document - The document to split.
startPage - The first page you want extracted (inclusive)
endPage - The last page you want extracted (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


Copyright © 2002-2012 Apache Software Foundation. All Rights Reserved.