Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snappdf generation doesnt work on Mac #26

Open
gbloggs opened this issue May 25, 2022 · 7 comments
Open

snappdf generation doesnt work on Mac #26

gbloggs opened this issue May 25, 2022 · 7 comments

Comments

@gbloggs
Copy link

gbloggs commented May 25, 2022

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
@beganovich
Copy link
Owner

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.

@gbloggs
Copy link
Author

gbloggs commented Jun 8, 2022

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.

@beganovich
Copy link
Owner

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?

@gbloggs
Copy link
Author

gbloggs commented Oct 29, 2023

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)?

@beganovich
Copy link
Owner

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

@gbloggs
Copy link
Author

gbloggs commented Nov 13, 2023

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:
invoiceninja/invoiceninja#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

@Striffly
Copy link

Striffly commented Dec 17, 2024

In case somebody have the same problem, I got the following hotfix :

  • install Chromium on Mac : https://github.com/ungoogled-software/ungoogled-chromium-macos
  • for those who use invoiceninja, add this into your .env : SNAPPDF_EXECUTABLE_PATH='/Applications/Chromium.app/Contents/MacOS/Chromium'
  • test everything works with this command : ./vendor/bin/snappdf convert --binary /Applications/Chromium.app/Contents/MacOS/Chromium' --html "<h1>Hello world!</h1>" test.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants