Class Splitter


  • public class Splitter
    extends Object
    Splits a pdf file into smaller pdfs using different criteria.
    Since:
    8.4
    Author:
    Marco Meschieri - LogicalDOC
    • Constructor Detail

      • Splitter

        public Splitter​(File src,
                        File dst)
    • 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 Barcode
        separator - 0 = skip the separator, 1 = last page of segment, 2 = first page of segment
        tenant - 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 Barcode
        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
        com.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 document
        policy - the splitting policy, one of the POLICY_xxx
        separator - how to handle the separator: 0 = skip, 1 = append to current segment, 2 = prepend to next segment
        expression - 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