1

following the simple instructions in this answer: https://askubuntu.com/a/1048975 I installed pdftk as a snap on an ubuntu 18.04 VM. (we need some of the advanced features of pdftk on the command line like fill_forms ).

my problem: the command seems to be only half installed:

/some/path # pdftk
-> Usage:
  pdftk <command>

Install, configure, refresh and remove snap packages. Snaps are
'universal' packages that work across many different Linux systems,
enabling secure distribution of the latest apps and utilities for
cloud, servers, desktops and the internet of things.

This is the CLI for snapd, a background service that takes care of
snaps on the system. Start with 'snap list' to see installed snaps.

Available commands:
< long list of snap commands >

so it seems to me as if 'pdftk' is registered as a tool in the bash, but if I try to use any of the usual pdftk commands, I get an error message like this:

pdftk forms/Form_FM.pdf fill_form /tmp/adsh/2017-4_1532602497.fdf output /some/path/2017-4_KF.pdf
-> error: unknown command forms/Form_FM.pdf, see 'snap help'

(this also happens with every other command I tried) so, how do I pass the commands and parameter to pdftk without snap trying to grab the parameter for itself?

edit: some diagnostics:

ls -l /usr/local/bin/pdftk
lrwxrwxrwx 1 root root 28 Jul 11 18:17 /usr/local/bin/pdftk -> /snap/bin/pdftk-smoser.pdftk

snap list pdftk 
error: no matching snaps installed

snap list pdftk-smoser
Name          Version  Rev  Tracking  Developer  Notes
pdftk-smoser  2.02-4   18   stable    smoser     -

hmmm...seems like I followed the older version of the answer, which had an additional step that symlinked /snap/bin/pdftk-smoser.pdftk to /usr/local/bin/pdftk

cypherabe
  • 121
  • Hi cypherabe! Welcome to askUbuntu! The third argument of your command is /tmp/adsh/2017-4_1532602497.fdf, but it should be /tmp/adsh/2017-4_1532602497.pdf (misspelled pdf) – abu_bua Jul 26 '18 at 11:46
  • 2
    Hmm... it actually looks like you're getting the usage information for the snap command (but with the command name pdftk), rather than that of the pdftk command itself - I wonder what could have gone wrong? Did you by any chance make a symbolic link? – steeldriver Jul 26 '18 at 12:02
  • ... can you add the output of type -a pdftk please? – steeldriver Jul 26 '18 at 12:13
  • @steeldriver type -a pdftk -> pdftk is /usr/local/bin/pdftk yes, I am wondering too. first time I use a snap, the examples seemed just so simple... – cypherabe Jul 26 '18 at 13:18
  • @abu_bua: thanks, but no, that's correct, .fdf files are datafiles to fill in a pdf formular (the call works with normal pdftk on ubuntu 16.04 machines) – cypherabe Jul 26 '18 at 13:19
  • @cypherabe my guess is that /usr/local/bin/pdftk is a symbolic link to /usr/bin/snap (which should work, provided the pdftk snap is present). Please [edit] your question to include ls -l /usr/local/bin/pdftk and snap list pdftk – steeldriver Jul 26 '18 at 13:31
  • updated: yes, there is a symlink, i guess snap has a problem with it somehow – cypherabe Jul 26 '18 at 13:51
  • 1
    I don't know why that wouldn't work, however it's a more complicated than it needs to be - the snap is now available as plain pdftk and /snap/bin has been part of the default Ubuntu PATH for some time now - I suggest you remove both the symlink and the pdftk-smoser snap and snap install pdftk instead – steeldriver Jul 26 '18 at 14:48

1 Answers1

1

As steeldriver suggested, I ended up with removing the symlink, removing the pdftk-smoser snap, then installing the pdftk snap and finally creating a new symlink for /usr/local/bin/pdftk to /snap/bin/pdftk

now a call to pdftk on the commandline brings up the pdftk usage hint, not something snap related

a caveat: I still can't access my pdf files, but at least I get pdftk error messages now. I'm not sure if it is a snap problem, an apparmor problem or a general rights problem...but if I can't find a solution that will be a new question

cypherabe
  • 121
  • You could also try a fork based of pdftk depending on OpenJDK as described here: https://askubuntu.com/questions/1028522/how-can-i-install-pdftk-in-ubuntu-18-04-bionic/1028983#1028983 . This worked flawlessly for me. – Bruni Jul 26 '18 at 15:20
  • 1
    As described in https://github.com/smoser/pdftk/issues/1 , snap cannot access files in /tmp. The easiest workaround is to copy the files to your home directory and use them from there. – smoser Sep 05 '18 at 13:15