(Screenshots at the bottom)
Updated 30 August 2008 to work with spaces in paths.

Works two ways:
1 - you call it without any input arguments, and you get a gui to specify the output file, a folder with the input files, and whether or not you want to view the file it creates.
2 - you call it from the command line with input files and/or folders, or drop things on it or use it from the rox "open with" menu or something. It will pop up a dialogue asking where you want to save it, and whether or not you want to view the file it creates (if you want to be able to use it from the console without popping up a dialogue then I'm sure you're smart enough to modify it to do that).

It will join all the .pdf files in a folder recursively, sorted in alphanumeric path order. e.g. if I do

Code:

joinPdf /~/pdf

for a hypothetical folder, it will join all the files together in this order:

However, if I run it from the command line with more than one input argument (files or folders or both), then it will join them in the order I specify. So if I do

Code:

joinpdf z b.pdf a

then it will first do the pdfs in folder z, in alphanumeric order, then it will add b.pdf, and then it will add the pdfs in folder a in alphanumeric order.

Requires gtkdialog3 (included in recent Puppies) and ghostscript of course.
Has no error handling to deal with ghostscript errors.
Doesn't check whether you want to overwrite if you specify an output file that already exists - just overwrites automatically.
Works recursively with pdfs in any depth of folders.
Isn't phased by folders containing files that aren't pdfs
Does make sure the output file has a .pdf extension but not a .pdf.pdf extension.

The full code at the moment:

Code:

#! /bin/bash
# Script for Puppy Linux to combine pdf files.
# Version 4 by disciple, 30 August 2008.
# http://www.murga-linux.com/puppy/viewtopic.php?p=149208#149208
# Currently has NO ERROR HANDLING
# You may experience errors if you have pdfs that are broken or are not pdfs at all.
# I'm not sure, but because it doesn't delete the temporary directory at the start, you may also get unexpected results if you use "View the file afterwards", crash your Pdf viewer, and then join some more pdfs.
# Yes, the use of all those symlinks is an ugly hack, but I couldn't get gs to join files with spaces in the path otherwise :(

export HELP_DIALOG="
<window title=\"joinPdf info\"icon-name=\"gtk-dialog-info\">
<vbox>
<text>
<label>If you run joinPdf from the command line with inputs, it will pop up a dialogue to ask you what you want to save the combined file as, and will then join them as you would expect. If you specify more than one input (file or folder), it will join them in the order that you specify, and things that it joins recursively are sorted globally (per input). They are deliberately not sorted folders first and then files.</label>
</text>
<text>
<label>\"\"</label>
</text>
<text>
<label>The file chooser for the output file can only choose a directory - you need to add a filename, but the script will sort out the .pdf extension.</label>
</text>
<hbox>
<button>
<label>\"Visit forum thread\"</label>
<action>defaultbrowser http://www.murga-linux.com/puppy/viewtopic.php?p=149208#149208</action>
</button>
<button ok></button>
</hbox>
</vbox>
</window>
"

i'll be interested to try it out. until your post i didn't realise that you could use GS to join pdf files...i've been using pdftk. i'll see how the output .pdf compares from both, e.g. final file size.

if i've dloaded a book, where the various chapters are available as separate .pdfs, i'm in the habit of using pdftk to concatenate them all into one .pdf. one side effect of doing so is that the resultant .pdf is smaller in size than the sum of the parts. i usually go further, to reduce disk usage, by making the resultant .pdf into a self-extracting archive.

you'll have to excuse my ignorance . i sat for english, for my higher school certificate, at the lowest level possible & failed, but i've got know idea what The Books are protectrd and, well???? means. perhaps i'll have to dig out some joyce books from the library, a uni course in semiotics &/or deconstructionalism, and grow some peyote, to get your drift.

johnbiles:

i just copied & pasted it, as a script, to /usr/bin & gave it executable permission. i still haven't gotten around to trying it on any pdf's yet, but will do for sure, and report back results.

Q - Why would we want to join PDFs?
A - Sometimes I have a whole lot of small pdfs from some lecturer, e.g. several sheets of tutorial questions, and also answers, and I want to print them out all together, say two to a page and double-sided, so I can cram for a test. I imagine it is possible to print multiple files like this with some obscure command, but it is easier to join them together. (BTW I also find it easiest to use GTKLPQ (do a forum search for it) to do stuff like printing two-up, but I guess if ePDF is now in Puppy it might have a proper printer interface).
Also, sometimes I want to join several types of file together into one pdf to electronically submit an assignment. Until I discovered the gs command I used pdf995 (a windows pdf printer) and pdfedit995 (which lets you append a file to the last one you print), but now I can use jcoder's (AD-FREE!) pdf printer and this.
Or, like muggins, you might find it convenient to join together the parts of some (maybe official) document you downloaded.

At work (a civil engineering consultancy) we always archive big reports and manuals and stuff as PDF, and the main reason we use Adobe Acrobat is for joining files together. As far as I know, Acrobat can't do what this script does, which I think is far more efficient than joining files manually in Acrobat, but of course with this if you have two pages in the wrong order you can't just click and swap them around. I designed the script specifically for this sort of task, where you have a lot of files you want to join together that might be in different folders for different sections and subsections, and stuff, and it is natural to name the files in an organised way anyway.

Anyway, with this script I no longer feel the need to get pdfedit to compile in my Puppy
-----------------------
john biles - Yes - just put that code in a file in /usr/bin or /usr/local/bin (I think these places are most appropriate), and make it executable.
If someone wants to make a dotpup with a roxapp and a menu entry, feel free. I didn't really feel inclined to take it further at the moment since I can't get it to work with paths with spaces.
-----------------------
Muggins - it would depend why they are smaller when you join them together. If it is because they are saved in a more "compressed" way somehow, or have embedded fonts removed or something, then my script won't make them smaller - I think it just joins the raw pdfs together. But if one pdf is inherently smaller than two pdfs half the size... well that seems funny. What happens if you print them again? Because you can change some sort of quality settings in the CUPS pdf printer. Maybe you could join them together and then print them out even smaller... but I guess pdftk does quality settings anyway.

I like my script. It is useful and light and easy to use. I just wish it would work with spaces...

Ah. Apparently gtkdialog3 was introduced with Puppy 2.15 - you can get the pet here.

I've actually only tested the script in Grafpup 104, which I use even though it's as old as the hills - so you'll have no problem with the gui itself. I just probably should have checked that the same gs command still works in newer puppies.

You also need gtkdialog3 for the newer versions of Pfind and several of the other wonderful guis people have done. Personally I think every user of an older Puppy should get gtkdialog3 just for the sake of Pfind

That size difference is interesting, but it would be strange if it scaled up for bigger files. If you're so worried about size, why haven't you checked out pdftk's claim to be able to recompress pdf's?

If for some reason there is an advantage to pdftk, it would actually be very simple to adapt the gui to use it, or for that matter to do other things. Incidentally, I tried the Pdftk gui on windows a long time ago, and could never figure it out. I hadn't been enlightened about the command line This is just my attempt to make something a little more user friendly than it.

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum