1

I have a website which uses PDFTK.

My site allows users to send PDF files via a form, then, at the click of a button, launches a combination of all files to create one.

When sending my files, my apache user is assigned.

Except that when I run the command line, it does not work. If I pass all my files in user and group root, the command line is passed. Except that I have a manual action to do what is not possible for the proper functioning of my site.

This is my command with the error:

$ /snap/bin/pdftk "upload/418/2018/fichier1.pdf" cat output upload/418/2018/fichiercombine.pdf dont_ask
Error: Unable to find file.
Error: Failed to open PDF file:
   upload/418/2018/fichier1.pdf
Errors encountered.  No output created.
Done.  Input errors, so no output created.

This is a good command but with chown:

chown -R root:root upload/418/2018
/snap/bin/pdftk "upload/418/2018/fichier1.pdf" cat output upload/418/2018/fichiercombine.pdf dont_ask

What could be the problem here?

1

This command that works according to you:

chown -R root:root upload/418/2018
/snap/bin/pdftk "upload/418/2018/fichier1.pdf" cat output upload/418/2018/fichiercombine.pdf dont_ask

was preceeded by a change directory (something like cd /var/www/html/).

This one did not do that:

$ /snap/bin/pdftk "upload/418/2018/fichier1.pdf" cat output upload/418/2018/fichiercombine.pdf dont_ask
Error: Unable to find file.
Error: Failed to open PDF file:
   upload/418/2018/fichier1.pdf
Errors encountered.  No output created.
Done.  Input errors, so no output created.

... so will try to execute it from inside a directory that does start where you put upload/ The notice does not complain about permissions so I would assume that is not the problem. It says "file not found" instead so I believe your 2nd command is not executed at the correct directory. If it is though a permission issue: add the user apache to the group that owns pdftk or, if that is owned by root, change the group for that to a new group and add apache to it.

If it is a directory issuue the asiest fix would be to use absolute paths and not relative paths. Or add a cd /var/www/html && in front of the command where you replace the /var/www/html for what it needs to be.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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