peter-de-boer

peter-de-boer

Generator_failed error when using elixir-pdf-generator

I am trying to use GitHub - gutschilla/elixir-pdf-generator: Create PDFs with wkhtmltopdf or puppeteer/chromium from Elixir. · GitHub 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?

First Post!

maxi

maxi

facing the same problem here

Last Post!

olivermt

olivermt

I would try Chromic, seems to be the best lib around these days.

Where Next?

Popular in Questions Top

Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 130286 1222
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31494 112
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44139 214
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

We're in Beta

About us Mission Statement