coletiv / puppeteer-pdf

PDF generation wrapper for Elixir using Puppeteer
MIT License
97 stars 18 forks source link

How to use in a Elixir Mix Project Locally with out -g option ? #29

Closed blackode closed 4 years ago

blackode commented 4 years ago

I am trying to use puppeteer-pdf locally in a mix project.

I installed locally by running npm install puppeteer-pdf.

This created a folder node_modules and inside it has two folders named puppeteer and puppeteer-pdf with some dependencies.

In my config.ex, I configured the executable path to node_modules/puppeteer-pdf

config :puppeteer_pdf, exec_path: Path.join(File.cwd!(), "node_modules/puppeteer-pdf")

After compiling, I tried to check version and generate a file from string like in the following way

iex> PuppeteerPdf.get_exec_version()
""
iex> PuppeteerPdf.Generate.from_string "hello pdf", "pdfs/hello.pdf"
{:ok, ""}

I am not getting any errors nor pdf's generated.

Am I missing Something here?

blackode commented 4 years ago

BTW, I resolved by updating config with following LOC in config.ex

config :puppeteer_pdf, 
  exec_path: Path.join(File.cwd!(), "node_modules/.bin/puppeteer-pdf")
tmpduarte commented 4 years ago

Hi @blackode sorry for taking some time to answer.

Glad you found a solution! We will probably include this solution in the readme, thank you for the contribution

blackode commented 4 years ago

Hi @tmpduarte Firstly, Thanks for amazing library :) Glad to hear that..