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 Details

  • Constructor Details

    • Splitter

      public Splitter(File src, File dst)
  • Method Details

    • splitAllPages

      public List<File> splitAllPages() throws IOException, FeatureNotEnabledException
      Splits every page in a separate single page PDF
      Returns:
      the list of splits
      Throws:
      IOException - cannot read the PDF file
      FeatureNotEnabledException - Feature is not enabled in the license
    • splitSelection

      public List<File> splitSelection(String expression) throws IOException, FeatureNotEnabledException
      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
      FeatureNotEnabledException - Feature is not enabled in the license
    • getSegmentsFromExpression

      public static List<List<Integer>> getSegmentsFromExpression(String expression)
    • splitUsingBarcode

      public List<File> splitUsingBarcode(String expression, String tenant, int separator) throws IOException, FeatureNotEnabledException
      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
      FeatureNotEnabledException - Feature is not enabled in the license
    • splitUsingText

      public List<File> splitUsingText(String expression, int separator) throws IOException, com.logicaldoc.core.parser.ParsingException, FeatureNotEnabledException
      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.ParsingException - in case of error during the parsing
      FeatureNotEnabledException - Feature is not enabled in the license
    • splitUsingBlankPage

      public List<File> splitUsingBlankPage(int separator) throws IOException, FeatureNotEnabledException
      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
      FeatureNotEnabledException - Feature is not enabled in the license
    • getSplits

      public List<File> getSplits(String prefix)
    • 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 IOException, com.logicaldoc.core.PersistenceException, com.logicaldoc.core.security.authorization.PermissionException, FeatureNotEnabledException, com.logicaldoc.core.parser.ParsingException
      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:
      IOException - I/O error
      com.logicaldoc.core.PersistenceException - Error in the data layer
      com.logicaldoc.core.security.authorization.PermissionException - The user does not have enough permissions
      FeatureNotEnabledException - The feature is not enabled in the license
      com.logicaldoc.core.parser.ParsingException - Error parsing the document file