Skip to content

Instantly share code, notes, and snippets.

@mjm522
Last active November 18, 2019 11:15
Show Gist options
  • Save mjm522/ae3a38f51b7083cf0047811862f6e000 to your computer and use it in GitHub Desktop.
Save mjm522/ae3a38f51b7083cf0047811862f6e000 to your computer and use it in GitHub Desktop.
Combining pdfs in Ubuntu
Add this function to the `~/.bashrc` file or keep as a shell script file.
```
function combine_pdfs()
{
output_file=$1
files=($2)
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -dAutoRotatePages=/None -sOutputFile=$output_file "${files[@]}"
}
```
Remember to source the file. Then in a terminal in the folder containing the files type:
Usage: combine_pdfs blah_blah.pdf 'first.pdf second.pdf third.pdf fourth.pdf'
The above script will create a file `blah.pdf` which is a combination of `first.pdf`, `second.pdf` and `third.pdf`.
@mjm522
Copy link
Author

mjm522 commented Nov 18, 2019

Add the this function to the ~/.bashrc file or keep as a shell script file.

function combine_pdfs()
{
    output_file=$1
    files=($2)
    gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -dAutoRotatePages=/None -sOutputFile=$output_file "${files[@]}"
}

Remember to source the file. Then in a terminal in the folder containing the files type:

Usage: combine_pdfs blah_blah.pdf 'first.pdf second.pdf third.pdf fourth.pdf'

The above script will create a file blah.pdf which is a combination of first.pdf, second.pdf and third.pdf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment