24eme / signaturepdf

Free open-source web software for signing PDFs (alone or with others) and also organize pages, edit medata and compress pdf
https://pdf.24eme.fr
GNU Affero General Public License v3.0
396 stars 51 forks source link

Alpine issue #35

Closed battosai30 closed 2 years ago

battosai30 commented 2 years ago

Hi guys,

Very cool project :)

As I like to work with Proxmox and Alpine containers, I tried this environnement to install signaturepdf.

So :

Everything works except when I try to download the signed pdf : I see a POST /sign with HTTP 200 response, but the screen stay white. No error in logs ...

If you have any clue ...

It's not a emergency at all, I installed it with success in a Debian container + apache + php7.4, it's just curiosity and if I can stay on Alpine I prefer ;)

Regards

wincelau commented 2 years ago

Very cool project :)

Thank you :-)

Everything works except when I try to download the signed pdf : I see a POST /sign with HTTP 200 response, but the screen stay white. No error in logs ...

If you have any clue ...

You can activate debug mode in this file https://github.com/24eme/signaturepdf/blob/master/app.php#L8 by adding this php line :

$f3->set('DEBUG', true);

And i hope you have some errors in your white screen.

battosai30 commented 2 years ago

Setting DEBUG mode doesn't show errors. I took some time to dig in app.php, I found that pdftk was missing (it's a little bit tricky on Alpine) but apparently it's not enough, still blank screen. So I will dig more ...

battosai30 commented 2 years ago

Ok so here I am :

I had some "echo" and took a look at files genrated in /tmp In app.php I found that the problem seems to come from this line : shell_exec(sprintf("pdftk %s multistamp %s output %s", $tmpfile.".pdf", $tmpfile.'.svg.pdf', $tmpfile.'_signe.pdf')); I know the problem comes from here because .svg.pdf file is well generated from the previous line, and _signe file doesn't exist (and the line Web::instance()->send($tmpfile.'_signe.pdf', null, 0, TRUE, $filename) after return false as the file doesn't exist).

And here comes the strange thing : I echo the result of the sprintf() and I executed it in the shell using nginx user => it works ! Ok ... I write a test.php file with the shell_exec() and the result of the sprintf() => it works ! OOOOOOkkkkkkkK ....

battosai30 commented 2 years ago

Oh god I found ! On Alpine pdftk is a little bit tricky to install. I followed a tutorial that installs it in /usr/local/bin I don't know why but it appears taht specially in your app, this path does not seems to be included in $PATH so pdftk => KO /usr/local/bin => OK So I moved pdftk to /usr/bin (where rsvg-convert is) and now it's working well :)

I will make a pull request on your readme to explain how to install it on Alpine ;)

wincelau commented 2 years ago

Happy that you found a solution and thank you for sharing :-) !