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.

So:
- All the PDF files in PDF FOLDER 1 will be merged as a single PDF and the output file called PDF FOLDER 1.
- All the PDF files in Sub-Directory PDF FOLDER 2 will be merged as a single PDF and the output file called PDF FOLDER 2

Thanks for you reply,
blivori

July 26th, 2011, 09:00 AM

Norm

Re: Merging PDF Files using PDFBox in Sub/Directories

I'm not sure about how to preserve the contents of a PDF file, but for text files:
Open output file
begin loop to work thru a list of files
copy next file to output file
end loop
close output file

July 26th, 2011, 09:03 AM

blivori

Re: Merging PDF Files using PDFBox in Sub/Directories

I was trying to acheive it by using PDFBox.

It can be done.

The problem is how to get the files in the directory and sub-directory, add them to some kind of array or db, and link them with the PDFBox Merger Utility

July 26th, 2011, 09:53 AM

Norm

Re: Merging PDF Files using PDFBox in Sub/Directories

Is this a question of reading API doc for the PDFBox Merger utility to understand how to use it?

July 26th, 2011, 09:59 AM

blivori

Re: Merging PDF Files using PDFBox in Sub/Directories

Kind of..

I just want to know how to save the files in some sort of array or database and the use the PDFBox Merger Utility to rename it according to the folder/sub-folder the original PDF files where stored in.