Results 1 to 2 of 2
  1. #1
    blivori is offline Member
    Join Date
    Jul 2011
    Posts
    1
    Rep Power
    0

    Default Merging PDF Files using PDFBox in Sub/Directories

    Hi,

    I am currently trying to create a program that merges all the files in directories and sub-directories (automatically) and rename them according to the directory/sub0directory they are in. I am trying to acheive this using the PDFBox library.

    As of now I have found a script that reads all the files and folders in a directory and sub-directories.

    My problem is that I don't know how to acheive the merging of PDFs (i.e. merging the files and renaming them according to the folder name).

    I found a tutorial on how to merge files with PDFBox here but I need to apply it to do it automatically for all the files in the directories.

    The code that lists all the files and folders is this:

    Java Code:
    import java.io.File;
    
    public class Main {
    
      static int spc_count=-1;
    
      static void Process(File aFile) {
        spc_count++;
        String spcs = "";
        for (int i = 0; i < spc_count; i++)
          spcs += " ";
        if(aFile.isFile())
          System.out.println(spcs + "[FILE] " + aFile.getName());
        else if (aFile.isDirectory()) {
          System.out.println(spcs + "[DIR] " + aFile.getName());
          File[] listOfFiles = aFile.listFiles();
          if(listOfFiles!=null) {
            for (int i = 0; i < listOfFiles.length; i++)
              Process(listOfFiles[i]);
          } else {
            System.out.println(spcs + " [ACCESS DENIED]");
          }
        }
        spc_count--;
      }
    
      public static void main(String[] args) {
        String nam = "C:\\Documents and Settings\\student3\\Desktop\\PDFs";
        File aFile = new File(nam);
        Process(aFile);
      }
      
      
    
    }
    Any help please?

    Thanks & Regards,
    blivori

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

Similar Threads

  1. Merging multiple XML files
    By MarcoGT in forum XML
    Replies: 0
    Last Post: 07-09-2011, 01:59 PM
  2. Replies: 1
    Last Post: 07-07-2011, 09:04 PM
  3. Searching directories for folders and .txt files
    By XDrew574X in forum New To Java
    Replies: 1
    Last Post: 03-29-2011, 09:41 PM
  4. Save files in directories
    By Tota in forum New To Java
    Replies: 2
    Last Post: 09-02-2010, 02:49 PM
  5. List of files and directories.
    By artemff in forum CLDC and MIDP
    Replies: 6
    Last Post: 01-02-2010, 04:06 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •