2

This question already has an answer here:

As pdftk is not yet available on Ubuntu 18.04 I compiled a pdftk fork following this excellent answer to a related question.

This works great, however I now have to type

java -jar build/jar/pdftk.jar

to run pdftk.

I would like to just type pdftk with its respective options. I created a bash script, but this does ignore the command line options. Any ideas?

marked as duplicate by dessert, rɑːdʒɑ, karel, Fabby, waltinator May 1 '18 at 15:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

That's a case for alias: Open ~/.bash_aliases in your preferred text editor and add this line:

alias pdftk='java -jar build/jar/pdftk.jar'

Save the file and open up a new terminal window (or run . ~/.bash_aliases in an existing), pdftk should work with the syntax as you know it now.

  • I am not sure why you have added an answer while there is a similar duplicate question tagged already – rɑːdʒɑ May 1 '18 at 11:50
  • Can I just create such a file if it does not exist? I would prefer not writing this directly in .bashrc – Bruni May 1 '18 at 11:52
  • @Bruni Yes, or add the line to ~/.bashrc instead – as you like. – dessert May 1 '18 at 11:52
  • @Ten-Coin Simply because I'm not sure it suffices. There seems to be a concensus that this isn't a problem, see this meta question, especially this answer and the discussion in the comments. – dessert May 1 '18 at 11:56
1

Here a bash script for you

#!/bin/bash

exec java -jar /path/to/pdftk.jar "$@"

$@ is the variable you were looking for. It's all the argument you pass to the script that you pass on to pdftk.jar.

exec is to avoid another shell and replace it with java process.

Not the answer you're looking for? Browse other questions tagged or ask your own question.