Last week, I made the switch from Kubuntu 16.04 to the latest LTS — 18.04.
So far, I am satisfied the way Ubuntu and KDE Plasma are performing.
In order to get a Linux distribution working the way I want it, I use a short post-install checklist. This list takes about 10 to 15 minutes to complete.
When I’m done, I’ve installed every application and tool I need. In addition, SSH, Wi-Fi, hosts, fstab, user-dirs, places, and LibreOffice are properly configured.
Working my way through the checklist, I found that PDFtk is no longer available in the Ubuntu 18.04 repository. That was a disappointment.
The reason for this is a deprecated dependency, of the GCJ runtime to be precise. This is a shame, really.
The good news, is that PDFtk is available as a Snap package.
Installing PDFtk with snap is as easy as:
sudo snap install pdftk
However, when running a command like:
pdftk input.pdf cat output new.pdf
I’m faced with an error message:
Error: Unable to find file.
Error: Failed to open PDF file:
input.pdf
Errors encountered. No output created.
Done. Input errors, so no output created.
On first look, “Unable to find file” seems to be an input error. Which is a bit odd. After all, the input pdf file is there! I see it!
So, pdftk must have trouble finding the input file. Including the full path to the input file doesn’t resolve this issue.
The real problem, is that the pdftk command isn’t executed correctly.
Googling for ‘Ubuntu 18.04’ in combination with ‘pdftk’ returns several hits. Some workarounds are too complicated for my taste.
The solution that worked for me, was creating a symlink as follows:
sudo ln -s /snap/pdftk/current/usr/bin/pdftk /usr/bin/pdftk
In case you need to overwrite an existing symlink, just add the -f (force) option to overwrite the existing symbolic link.
sudo ln -fs /snap/pdftk/current/usr/bin/pdftk /usr/bin/pdftk
Now I’m able to perform a command again like:
pdftk input.pdf cat output new.pdf
Have fun!
Works like a charm. This saved my day, thank you!
Thanks a million for this, I would not have come up with this solution on my own. I regularly use pdftk and was about to miss a deadline when it wasn’t working on my new install.
Thank you! After spending an hour trying to figure this out, I came across your post.
Thank you for the workaround; I use Kubuntu 18.04 as well. I use pdftk often that I was quite inconvenienced with not being to use its capabilities.
I read above that you use a short post-install checklist to configure your new install the way you want it to use, including installing packages. Would you share your checklist so I can create one for myself? I have a few machines to update in my Nature Club, but cannot clone my system because of the size of partitions and tight disk space.
You’re most welcome, Fernando. It will be my pleasure to share my post-install checklist, I will post it in the cause of this week.
Thank you!
Thanks for this Wil. Unfortunately the fix didn’t work for me, but at least now I can be a little more confident that it’s a combination of Ubuntu 18.04 and pdftk, not anything to do with our configuration.
I’ll run the same search you mentioned (“Ubuntu 18.04 pdftk”) and see if I can find other workarounds.
Cheers,
Pablo
That’s too bad, Pablo. Are you able to pinpoint where it fails?
That’s works ! thank’s
Thank you very, very much! I just installed Ubuntu 18.04 and found, to my consternation, that pdftk was no longer available in the repositories. This web page gave me an easy way to install a program that I use a great deal. Thanks again.
Thank you! Working method
Thank you! is difficult to find this kind of solutions on Internet.
Successfully installed and Works on Mint 19.2.
I didn’t know snap-pdftk.
Thanks for your helpful advice !!
Same problem as Pablo’s. It didn’t work for me. I still obtain
“Error: Unable to find file.
Error: Failed to open PDF file:
draft.pdf
Errors encountered. No output created.
Done. Input errors, so no output created.”
after creating the symlink. Thank you anyway for your post.
Claudio, you get the errors you also see before installing the snap package and creating the symlink. My guess is that at least one of the two step fails.
Here’s a question. My trusty (and very old) Linux server turned up it’s toes a few days ago. In the meantime as a Q&D I’ve installed the Ubuntu Linux subsystem for Windows 10 on my household PC. It works surprisingly well. I tried to install pdftk (a tool I use a lot) and tripped over the removal from the repositories. So, I came across your post and tried to use snap.
I get the message:
“Interacting with snapd is not yet supported on Windows Subsystem for Linux. This command has been left available for documentation purposes only.”
The problem will go away when my new server arrives, but in the meantime, has anyone got any ideas?
Did you consider installing PDFtk for Windows
Thank You! I was in pain…
A heartfelt thank you, Wil. Such a simple, elegant solution that I regularly use for my own scripts, but never thought to try with my snap install of pdftk.
I use pdftk several _hundred_ times a day (literally – its part of an automated process archiving scans on my server at work) and this was a bit of a show stopper personally for me in terms of switching over my office to the new server.
Thanks a lot.
Thank you.
you save my project!
Thank you for this! It was so so helpful!