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

Generator_failed error #86

Open
peter-de-boer opened this issue Jun 11, 2021 · 4 comments
Open

Generator_failed error #86

peter-de-boer opened this issue Jun 11, 2021 · 4 comments
Labels

Comments

@peter-de-boer
Copy link

I am trying to use elixir-pdf-generator in my web app.
First I have tried to use it with wkhtmltopdf, but it seems it does not handle all css correctly
So, I am now using it with Chrome-headless/Puppeteer.
I have installed it according to:

Eventually, if you are using Phoenix and you would like to have your npm packages installed localy, within the /assets/node_modules directory, simply run npm install chrome-headless-render-pdf puppeteer within assets/node_modules and pass prefer_local_executable: true option when generating the PDF like this:

PdfGenerator.generate(url, generator: :chrome, prefer_local_executable: true)

Bit if I try it with an existing url, I get:

[debug] {"/usr/local/bin/node", ["/home/peter/bw/_build/dev/lib/pdf_generator/priv/node_modules/chrome-headless-render-pdf/dist/cli/chrome-headless-render-pdf.js", "--url", "http://localhost:4000/factuur/test", "--pdf", "/tmp/MlUkqisz.pdf", "--paper-width", "8.26772", "--paper-height", "11.695"]}
{:error,
 {:generator_failed,
  "internal/modules/cjs/loader.js:883\n  throw err;\n  ^\n\nError: Cannot find module '/home/peter/bw/_build/dev/lib/pdf_generator/priv/node_modules/chrome-headless-render-pdf/dist/cli/chrome-headless-render-pdf.js'\n    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)\n    at Function.Module._load (internal/modules/cjs/loader.js:725:27)\n    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)\n    at internal/main/run_main_module.js:17:47 {\n  code: 'MODULE_NOT_FOUND',\n  requireStack: []\n}\n"}}

Any ideas?

@yugandharc9
Copy link

Hi Peter was facing same problem solved by

cd deps/pdf_generator/priv && npm install

In my mix.exs

  { :pdf_generator, ">=0.6.2" },

@yugandharc9
Copy link

Used like this

 PdfGenerator.generate(html,page_size: "A3", delete_temporay: true,generator: :chrome, prefer_local_executable: true)

@jarvisjohnson
Copy link

these settings worked for me:

      PdfGenerator.generate(raw_html,
        page_size: "A4",
        prefer_local_executable: true
      )

I didn't have any config for the package in my config.exs, just that above with yarn add chrome-headless-render-pdf puppeteer in /assets

@gutschilla gutschilla added the bug label Jun 28, 2022
@gutschilla
Copy link
Owner

Thanks for pointing that out. This seems to be an incompatibility with newer Phoenixes

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

No branches or pull requests

4 participants