Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I have about 30 pdf files that I want as 1 pdf file. The command cat seems to be the answer to my problems - cat 1.pdf 2.pdf > new.pdf . I do not want to type the names of all the pdf files into this command (most of the file names are are long) so I hoped that cat *.pdf > new.pdf would give me what I need. It doesn't. new.pdf is created but it only contains the contents of the file 1.pdf --- none of the others. What am I missing? This is the first time I've used cat.
Thanks - I hope that I'm not missing something *too* obvious.
If the PDF document format supports this method of joining files (which I doubt) then the problem is in the use of >.
What you're doing is this:
cat file1.pdf > new.pdf Create a new file called new.pdf containing the contents of file1.pdf.
cat file2.pdf > new.pdf Create a new file, or overwrite existing file, called new.pdf containing the contents of file2.pdf.
You see the problem? Now, if you were to you >> (double chevron) then file2.pdf would be appended to new.pdf.
If you have lots of files you could do this (presuming they're all in one directory): for name in *.pdf (enter) do (enter) cat $name.pdf >> new.pdf (enter) done (enter)
Obviously, if you want finer control, you can change the above as such:
for name in 1 3 5 7 9
cat file$name.pdf > new.pdf
Hope this helps.
If this doesn't work because PDF doesn't support this method of concatenating, then you could:
Convert each PDF document into a series of image files.
Convert all the image files into a single PDF file.
This will probably be a touch more time consuming.
I think I did 10 files but it should work with any number. In order to make this work you have to type in "texconfig formats" and uncomment the line
I just checked in FC2 and it was already uncommented. The files you merge have to end in .pdf in order to work. The order you put the pdf's in is the order they will be merged in. I have not tried this on anything but red hat 9.0. Maybe someone else can help with a script. Good luck.
The first method is by using convert , directly from the ImageMagick toolkit. You probably already have this one installed on your favourite Linux distribution; if not, almost every known Linux distribution has a package for it. Even if you don't need to edit PDF files you should have it, it is a wonderful swiss army knife for command line image processing. The syntax for merging PDF files is simple:
convert file1.pdf file2.pdf file3.pdf out.pdf
(that is, the last file name is the output file name). This usually works quite correctly, but 1)it is slow 2)I found sometimes has issues with image resolution. So I looked for another solution, and I found pdftk. The name stands for "PDF ToolKit", and really it is. It is a free (open source under the GNU GPL), wonderful command line utility that with a bit of magic allows you to manage PDF files from the command line. It works on Linux, Windows and Mac. pdftk can merge PDF documents, split PDF pages into a new document, rotate PDF Pages or Documents, decrypt and encrypt, fill PDF forms, apply a background watermark or a foreground stamp, burst a PDF Document into single pages... whatever.
The syntax for merging with pdftk is almost as simple:
You just need to add the magic "cat output" between the input pdfs and the output file name. In comparison with convert, it is truly fast and in my experience gives better results. And it may come handy for when I have to work with PDF files in other ways. Also, KDE users may find nice PDF Concat, a Kommander script that acts as a simple pdftk frontend to merge PDFs.
texexec --pdfarrange --result newfile.pdf *.pdf
Last edited by frenchn00b; 11-21-2007 at 02:02 PM.