Package com.logicaldoc.split
Class Splitter
- java.lang.Object
-
- com.logicaldoc.split.Splitter
-
public class Splitter extends Object
Splits a pdf file into smaller pdfs using different criteria.- Since:
- 8.4
- Author:
- Marco Meschieri - LogicalDOC
-
-
Field Summary
Fields Modifier and Type Field Description static intPOLICY_ALLPAGESstatic intPOLICY_BARCODEstatic intPOLICY_BLANKPAGEstatic intPOLICY_SELECTIONstatic intPOLICY_TEXTstatic intSEPARATOR_CURRENTSEGstatic intSEPARATOR_NEXTSEGstatic intSEPARATOR_SKIP
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static List<List<Integer>>getSegmentsFromExpression(String expression)List<File>getSplits(String prefix)static List<com.logicaldoc.core.document.Document>split(long docId, int policy, int separator, String expression, com.logicaldoc.core.document.DocumentHistory transaction)Generic method for splittingList<File>splitAllPages()Splits every page in a separate single page PDFList<File>splitSelection(String expression)Splits in segments of pages depending on an expression(eg: 1,4-7,8)List<File>splitUsingBarcode(String expression, String tenant, int separator)Splits in segments using a barcodeList<File>splitUsingBlankPage(int separator)Splits in segments using a blank page as separatorList<File>splitUsingText(String expression, int separator)Splits in segments using a text expression
-
-
-
Field Detail
-
POLICY_ALLPAGES
public static final int POLICY_ALLPAGES
- See Also:
- Constant Field Values
-
POLICY_SELECTION
public static final int POLICY_SELECTION
- See Also:
- Constant Field Values
-
POLICY_BLANKPAGE
public static final int POLICY_BLANKPAGE
- See Also:
- Constant Field Values
-
POLICY_BARCODE
public static final int POLICY_BARCODE
- See Also:
- Constant Field Values
-
POLICY_TEXT
public static final int POLICY_TEXT
- See Also:
- Constant Field Values
-
SEPARATOR_SKIP
public static final int SEPARATOR_SKIP
- See Also:
- Constant Field Values
-
SEPARATOR_CURRENTSEG
public static final int SEPARATOR_CURRENTSEG
- See Also:
- Constant Field Values
-
SEPARATOR_NEXTSEG
public static final int SEPARATOR_NEXTSEG
- See Also:
- Constant Field Values
-
-
Method Detail
-
splitAllPages
public List<File> splitAllPages() throws IOException
Splits every page in a separate single page PDF- Returns:
- the list of splits
- Throws:
IOException- cannot read the PDF file
-
splitSelection
public List<File> splitSelection(String expression) throws IOException
Splits in segments of pages depending on an expression(eg: 1,4-7,8)- Parameters:
expression- the selection of pages (e.g.: 1,2,4-6,9)- Returns:
- the list of segments
- Throws:
IOException- cannot read the PDF file
-
getSegmentsFromExpression
public static List<List<Integer>> getSegmentsFromExpression(String expression)
-
splitUsingBarcode
public List<File> splitUsingBarcode(String expression, String tenant, int separator) throws IOException
Splits in segments using a barcode- Parameters:
expression- Expression that must be matched by the Barcodeseparator- 0 = skip the separator, 1 = last page of segment, 2 = first page of segmenttenant- name of the tenant- Returns:
- the list of segments
- Throws:
IOException- cannot read the PDF file
-
splitUsingText
public List<File> splitUsingText(String expression, int separator) throws IOException, com.logicaldoc.core.parser.ParseException
Splits in segments using a text expression- Parameters:
expression- Expression that must be matched by the Barcodeseparator- 0 = skip the separator, 1 = last page of segment, 2 = first page of segment- Returns:
- the list of splits
- Throws:
IOException- cannot read the PDF filecom.logicaldoc.core.parser.ParseException- in case of error during the parsing
-
splitUsingBlankPage
public List<File> splitUsingBlankPage(int separator) throws IOException
Splits in segments using a blank page as separator- Parameters:
separator- 0 = skip the separator, 1 = last page of segment, 2 = first page of segment- Returns:
- the list of splits
- Throws:
IOException- cannot read the PDF file
-
split
public static List<com.logicaldoc.core.document.Document> split(long docId, int policy, int separator, String expression, com.logicaldoc.core.document.DocumentHistory transaction) throws Exception
Generic method for splitting- Parameters:
docId- identifier of the documentpolicy- the splitting policy, one of thePOLICY_xxxseparator- how to handle the separator: 0 = skip, 1 = append to current segment, 2 = prepend to next segmentexpression- the expression to use (some policies support it)transaction- informations about the current transaction- Returns:
- the list of segments
- Throws:
Exception- generic error splitting the file
-
-