Class PDFPageSplitter
- java.lang.Object
-
- com.norconex.importer.handler.AbstractImporterHandler
-
- com.norconex.importer.handler.splitter.AbstractDocumentSplitter
-
- com.norconex.importer.handler.splitter.impl.PDFPageSplitter
-
- All Implemented Interfaces:
IXMLConfigurable,IImporterHandler,IDocumentSplitter
public class PDFPageSplitter extends AbstractDocumentSplitter implements IXMLConfigurable
Split PDFs pages so each pages are treated as individual documents. May not work on all PDFs (e.g., encrypted PDFs).
The original PDF is kept intact. If you want to eliminate it to keep only the split pages, make sure to filter it. You can do so by filtering out PDFs without one of these two fields added to each pages:
document.pdf.pageNumberordocument.pdf.numberOfPages. A filtering example:XML usage example:
<filter class="com.norconex.importer.handler.filter.impl.EmptyFilter" onMatch="exclude"> <fieldMatcher matchWhole="true"> document.pdf.pageNumber </fieldMatcher> </filter>By default this splitter restricts its use to
document.contentTypematchingapplication/pdf.Should be used as a pre-parse handler.
XML configuration usage:
<handler class="com.norconex.importer.handler.splitter.impl.PDFPageSplitter"> <!-- multiple "restrictTo" tags allowed (only one needs to match) --> <restrictTo> <fieldMatcher>(field-matching expression)</fieldMatcher> <valueMatcher>(value-matching expression)</valueMatcher> </restrictTo> <referencePagePrefix> (String to put before the page number is appended to the document reference. Default is "#".) </referencePagePrefix> </handler>XML usage example:
<handler class="PDFPageSplitter"> <referencePagePrefix>#page</referencePagePrefix> </handler>The above example will split PDFs and will append the page number to the original PDF reference as "#page1", "#page2", etc.
- Since:
- 2.9.0
- Author:
- Pascal Essiembre
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_REFERENCE_PAGE_PREFIXstatic StringDOC_PDF_PAGE_NOstatic StringDOC_PDF_TOTAL_PAGES
-
Constructor Summary
Constructors Constructor Description PDFPageSplitter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object other)StringgetReferencePagePrefix()inthashCode()protected voidloadHandlerFromXML(XML xml)Loads configuration settings specific to the implementing class.protected voidsaveHandlerToXML(XML xml)Saves configuration settings specific to the implementing class.voidsetReferencePagePrefix(String referencePagePrefix)protected List<Doc>splitApplicableDocument(HandlerDoc doc, InputStream input, OutputStream output, ParseState parseState)StringtoString()-
Methods inherited from class com.norconex.importer.handler.splitter.AbstractDocumentSplitter
splitDocument
-
Methods inherited from class com.norconex.importer.handler.AbstractImporterHandler
addRestriction, addRestriction, addRestrictions, clearRestrictions, detectCharsetIfBlank, getRestrictions, isApplicable, loadFromXML, removeRestriction, removeRestriction, saveToXML
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.norconex.commons.lang.xml.IXMLConfigurable
loadFromXML, saveToXML
-
-
-
-
Field Detail
-
DOC_PDF_PAGE_NO
public static final String DOC_PDF_PAGE_NO
- See Also:
- Constant Field Values
-
DOC_PDF_TOTAL_PAGES
public static final String DOC_PDF_TOTAL_PAGES
- See Also:
- Constant Field Values
-
DEFAULT_REFERENCE_PAGE_PREFIX
public static final String DEFAULT_REFERENCE_PAGE_PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
getReferencePagePrefix
public String getReferencePagePrefix()
-
setReferencePagePrefix
public void setReferencePagePrefix(String referencePagePrefix)
-
splitApplicableDocument
protected List<Doc> splitApplicableDocument(HandlerDoc doc, InputStream input, OutputStream output, ParseState parseState) throws ImporterHandlerException
- Specified by:
splitApplicableDocumentin classAbstractDocumentSplitter- Throws:
ImporterHandlerException
-
loadHandlerFromXML
protected void loadHandlerFromXML(XML xml)
Description copied from class:AbstractImporterHandlerLoads configuration settings specific to the implementing class.- Specified by:
loadHandlerFromXMLin classAbstractImporterHandler- Parameters:
xml- XML configuration
-
saveHandlerToXML
protected void saveHandlerToXML(XML xml)
Description copied from class:AbstractImporterHandlerSaves configuration settings specific to the implementing class.- Specified by:
saveHandlerToXMLin classAbstractImporterHandler- Parameters:
xml- the XML
-
equals
public boolean equals(Object other)
- Overrides:
equalsin classAbstractImporterHandler
-
hashCode
public int hashCode()
- Overrides:
hashCodein classAbstractImporterHandler
-
toString
public String toString()
- Overrides:
toStringin classAbstractImporterHandler
-
-