public class Splitter
extends java.lang.Object
Modifier and Type | Field | Description |
---|---|---|
protected PDDocument |
currentDocument |
The current PDF document that contains the splitted page.
|
protected int |
pageNumber |
The current page number that we are processing, zero based.
|
protected PDDocument |
pdfDocument |
The source PDF document.
|
Constructor | Description |
---|---|
Splitter() |
Modifier and Type | Method | Description |
---|---|---|
protected void |
createNewDocument() |
Create a new document to write the splitted contents to.
|
protected void |
createNewDocumentIfNecessary() |
Interface method, you can control where a document gets split by implementing
this method.
|
int |
getEndPage() |
This will return the end page.
|
int |
getSplitAtPage() |
This will return how many pages each split document will contain.
|
int |
getStartPage() |
This will return the start page.
|
protected boolean |
isNewDocNecessary() |
Check if it is necessary to create a new document.
|
protected void |
processNextPage(PDPage page) |
Interface to start processing a new page.
|
protected void |
processPages(java.util.List pages) |
Interface method to handle the start of the page processing.
|
void |
setEndPage(int end) |
This will set the end page.
|
void |
setSplitAtPage(int split) |
This will tell the splitting algorithm where to split the pages.
|
void |
setStartPage(int start) |
This will set the start page.
|
java.util.List<PDDocument> |
split(PDDocument document) |
This will take a document and split into several other documents.
|
protected PDDocument pdfDocument
protected PDDocument currentDocument
protected int pageNumber
public java.util.List<PDDocument> split(PDDocument document) throws java.io.IOException
document
- The document to split.java.io.IOException
- If there is an IOErrorpublic void setSplitAtPage(int split)
split
- The number of pages each split document should contain.public int getSplitAtPage()
public void setStartPage(int start)
start
- the start pagepublic int getStartPage()
public void setEndPage(int end)
end
- the end pagepublic int getEndPage()
protected void processPages(java.util.List pages) throws java.io.IOException
pages
- The list of pages from the source document.java.io.IOException
- If an IO error occurs.protected void createNewDocumentIfNecessary() throws java.io.IOException
protected void createNewDocumentIfNecessary()
{
if( isPrime( pageNumber ) )
{
super.createNewDocumentIfNecessary();
}
}
java.io.IOException
- If there is an error creating the new document.protected boolean isNewDocNecessary()
protected void createNewDocument() throws java.io.IOException
java.io.IOException
- If there is an problem creating the new document.protected void processNextPage(PDPage page) throws java.io.IOException
page
- The page that is about to get processed.java.io.IOException
- If there is an error creating the new document.