gutschilla / elixir-pdf-generator

Create PDFs with wkhtmltopdf or puppeteer/chromium from Elixir.
MIT License
332 stars 71 forks source link

Document `prefer_system_executable` for chrome-headless #55

Closed richeterre closed 5 years ago

richeterre commented 5 years ago

The recommended setup instructions for chrome-headless, which tell the user to install the dependencies globally using npm -g install, only work if we set prefer_system_executable: true in the generator options.

This should definitely be mentioned in the docs, as it currently requires digging through the code to find this line: https://github.com/gutschilla/elixir-pdf-generator/blob/master/lib/pdf_generator.ex#L184

gutschilla commented 5 years ago

Hi @richeterre – will be published with a bunch of other things in v0.5.5 later today. Thanks a lot for spotting the missing documentation and coming up with a PR. Veeerrrryy nice! :100:

gutschilla commented 5 years ago

Oh thanks for fixing the "shrome" typo as wee :grimacing:

richeterre commented 5 years ago

Awesome! If you could also add some instructions for getting chrome-headless to work on Heroku (e.g. what buildpacks to install etc), that would be 😑👌 Or even better, would it be possible to ship the dependencies via local node_modules?

gutschilla commented 5 years ago

I have no experience with Heroku, unfortunately. The current Heroku documentation is a contribution from a user. But I'll ask him.

For the node_modules one could link the package.json from _deps/pdf_generator/package.json to your project directory and run "npm install" there and configure the chrome-path accordingly.

The right way would be to have the external dependency downloaded in the "mix deps.get" task. I am right now unsure how to achieve this.

richeterre commented 5 years ago

The right way would be to have the external dependency downloaded in the "mix deps.get" task. I am right now unsure how to achieve this.

This sounds like the perfect way – no additional steps needed beside installing the library 👍 Perhaps you could open a "Help wanted" issue? I'm still quite a noob at this stuff, but could this package be useful?

I agree that the npm approach is not ideal, especially since for Phoenix apps there is already a package.json in the assets directory…