snappdf icon indicating copy to clipboard operation
snappdf copied to clipboard

snappdf generation doesnt work on Mac

Open gbloggs opened this issue 2 years ago • 7 comments

Attempting to generate a simple file fails

vendor/bin/snappdf convert --html=“<html></html>” g.pdf

...

In Snappdf.php line 232:
 The command “‘<dir>/vendor/beganovich/snappdf/versions/1007374-Mac/chrome-mac/Chromium.app’ ‘--he
 adless’ ‘--disable-gpu’ ‘--disable-translate’ ‘--disable-extensions’ ‘--disable-sync’ ‘--disable-background-networking’ ‘--disa
 ble-software-rasterizer’ ‘--disable-default-apps’ ‘--disable-dev-shm-usage’ ‘--safebrowsing-disable-auto-update’ ‘--run-all-com
 positor-stages-before-draw’ ‘--no-first-run’ ‘--no-margins’ ‘--no-sandbox’ ‘--print-to-pdf-no-header’ ‘--hide-scrollbars’ ‘--ig
 nore-certificate-errors’ ‘--print-to-pdf=/private/var/folders/6_/7ccw7k2946v3r9zjy924khqr0000gn/T/pdf_4bLQcK.pdf’ ‘/private/var
 /folders/6_/7ccw7k2946v3r9zjy924khqr0000gn/T/html_OxxjEt.html’” failed.
 Exit Code: 126(Invoked command cannot execute)
 Working directory: <dir>
 Output:
 ================
 Error Output:
 ================
 sh: <dir>vendor/beganovich/snappdf/versions/1007374-Mac/chrome-mac/Chromium.app: is a directory
 sh: line 0: exec: <dir>/vendor/beganovich/snappdf/versions/1007374-Mac/chrome-mac/Chromium.app: cannot execute: Undefined error: 0

gbloggs avatar May 25 '22 15:05 gbloggs

This look to me like issues with permissions. Unfortunately, I don't have access to Mac at the moment. Can you try to try to make it executable?

chmod +x /vendor/beganovich/snappdf/versions/1007374-Mac/chrome-mac/Chromium.app and try running the command again.

beganovich avatar May 28 '22 11:05 beganovich

Hi. Sorry for the delay... I dont have access to the mac 100% of the time, its a server, but managed to get to it today.

first thing is:

/vendor/beganovich/snappdf/versions/1007374-Mac/chrome-mac/Chromium.app: is a directory

I could make the directory executable but not sure thats what is desired?

I have no knowledge of Chromium, sorry and not the best mac user around either, but traversing the tree there is a file called Chromium here:

/vendor/beganovich/snappdf/versions/1007374-Mac/chrome-mac/Chromium.app/Contents/MacOS

I've tried to make this executable and then run it. Something happens but not sure if its supposed to stay up as after a few seconds the executable terminates. I can try to be a little more responsive if you need me to try anything else.

gbloggs avatar Jun 08 '22 17:06 gbloggs

Chromium.app is directory? Can you manually download the Chromium application from this URL: https://commondatastorage.googleapis.com/chromium-browser-snapshots/Mac/1012408/chrome-mac.zip

After extracting it should give you Chromium.app file. Is it archive or single file you can execute?

beganovich avatar Jun 09 '22 10:06 beganovich

wow, fancy bringing this back to life after so long... The zip file has the executable in this structure: chrome-mac.zip\chrome-mac\Chromium.app\Contents\MacOS\Chromium The Chormium file is not exectuable. I have tried to make it exectuable and it does respond:

Chormium --version Chromium 120.0.6097.0

I've also tried to set the chromium path: ->setChromiumPath('<app>/vendor/beganovich/snappdf/versions/1216687-Mac/chrome-mac/Chromium.app/Contents/MacOS/Chromium') and this fails too. Also tried: ->setChromiumPath('<app>/vendor/beganovich/snappdf/versions/1216687-Mac/chrome-mac/Chromium.app/Contents/MacOS/') and ->setChromiumPath('<app>/vendor/beganovich/snappdf/versions/1216687-Mac/chrome-mac/Chromium.app/Contents/MacOS')

Nothing woked. Could it be snappdf is calling Chromium chromium?? (lowercase c)?

gbloggs avatar Oct 29 '23 19:10 gbloggs

Can you point environment and see if that work? SNAPPDF_EXECUTABLE_PATH.

beganovich avatar Nov 13 '23 17:11 beganovich

I have tried this too, and get the same result, i.e. no pdf -- a 500 error. I realised I have not stated that SNAPPDF is being used in invoiceninja and that I have also configured .env inline with this: https://github.com/invoiceninja/invoiceninja/issues/4841

Neither SNAPPDF_CHROMIUM_PATH nor SNAPPDF_EXECUTABLE_PATH allow pdf generation on a mac with any of the paths above configured against these variables

gbloggs avatar Nov 13 '23 18:11 gbloggs