1

I need to use PDFTK. It works when I use it in terminal as root, but when I try to use it with www-data I'm consistently getting a permission error.

When switching to www-data:

sudo -u www-data sh

and executing:

fpdtk simply.pdf generate_fdf output fields.fdf

I get this output:

Error: Unable to find file.
Error: Failed to open PDF file:
simply.pdf
Errors encountered.  No output created.
Done. Input errors, so no output created.

It seems the issue is that permission is denied for www-data user.

How can I change this?

2
  • Why do you think it is a permission problem? pdftk complains about not finding the file. Is the file in your current folder?
    – vanadium
    Jan 12, 2020 at 13:27
  • yes you were right, the issue was with just the current folder permission was, which owner is different than www-data
    – Andrewboy
    Jan 13, 2020 at 17:56

2 Answers 2

3

This article saved my life! I has the same error using the pdftk snap.

Simply create a symlink with this command:

sudo ln -s /snap/pdftk/current/usr/bin/pdftk /usr/bin/pdftk
1
  • 1
    Helpful, but the link is dead, so we do not know why it works. This is why it should be better to always add the relevant information in the answer...
    – Rmano
    Nov 2, 2022 at 9:47
0

The issue was that the current folder was not owned by www-data. So be sure that the the owner is the same as the apache user(www-data or daemon)

2
  • what was your solution for that ?
    – hous
    Nov 16, 2021 at 8:34
  • sudo chown www-data <directory_name>
    – Andrewboy
    Nov 17, 2021 at 23:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .