Package org.apache.pdfbox.util

Examples of org.apache.pdfbox.util.Splitter


      PDFParser parser = PDFBox.read(source);
      parser.parse();

      PDDocument document = parser.getPDDocument();

      Splitter splitter = new Splitter();
      splitter.setSplitAtPage(1);

      List<PDDocument> list = splitter.split(document);
      int pageCount = list.size();

      int startPage = start.intValue();
      if (startPage < 1) {
        startPage = 1;
View Full Code Here


      PDFParser parser = PDFBox.read(source);
      parser.parse();

      PDDocument document = parser.getPDDocument();
      Splitter splitter = new Splitter();
      splitter.setSplitAtPage(size.intValue());

      List<PDDocument> list = splitter.split(document);
      InputStream[] array = new InputStream[list.size()];

      for (int i = 0; i < list.size(); i++) {
        PDDocument d = list.get(i);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
View Full Code Here

      PDFParser parser = new PDFParser(source);
      parser.parse();

      PDDocument document = parser.getPDDocument();

      Splitter splitter = new Splitter();
      splitter.setSplitAtPage(1);

      List<PDDocument> list = splitter.split(document);
      int pageCount = list.size();

      int startPage = start;
      if (startPage < 1) {
        startPage = 1;
View Full Code Here

      PDFParser parser = new PDFParser(source);
      parser.parse();

      PDDocument document = parser.getPDDocument();
      Splitter splitter = new Splitter();
      splitter.setSplitAtPage(size);

      List<PDDocument> list = splitter.split(document);
      InputStream[] array = new InputStream[list.size()];

      for (int i = 0; i < list.size(); i++) {
        PDDocument d = list.get(i);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
View Full Code Here

    private void split( String[] args ) throws Exception
    {
        String password = "";
        String split = "1";

        Splitter splitter = new Splitter();
        String pdfFile = null;
        for( int i=0; i<args.length; i++ )
        {
            if( args[i].equals( PASSWORD ) )
            {
                i++;
                if( i >= args.length )
                {
                    usage();
                }
                password = args[i];
            }
            else if( args[i].equals( SPLIT ) )
            {
                i++;
                if( i >= args.length )
                {
                    usage();
                }
                split = args[i];
            }
            else
            {
                if( pdfFile == null )
                {
                    pdfFile = args[i];
                }
            }
        }

        if( pdfFile == null )
        {
            usage();
        }
        else
        {

            InputStream input = null;
            PDDocument document = null;
            List documents = null;
            try
            {
                input = new FileInputStream( pdfFile );
                document = parseDocument( input );

                if( document.isEncrypted() )
                {
                    try
                    {
                        document.decrypt( password );
                    }
                    catch( InvalidPasswordException e )
                    {
                        if( args.length == 4 )//they supplied the wrong password
                        {
                            System.err.println( "Error: The supplied password is incorrect." );
                            System.exit( 2 );
                        }
                        else
                        {
                            //they didn't suppply a password and the default of "" was wrong.
                            System.err.println( "Error: The document is encrypted." );
                            usage();
                        }
                    }
                }

                splitter.setSplitAtPage( Integer.parseInt( split ) );
                documents = splitter.split( document );
                for( int i=0; i<documents.size(); i++ )
                {
                    PDDocument doc = (PDDocument)documents.get( i );
                    String fileName = pdfFile.substring(0, pdfFile.length()-4 ) + "-" + i + ".pdf";
                    writeDocument( doc, fileName );
View Full Code Here

TOP

Related Classes of org.apache.pdfbox.util.Splitter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.