Elixir-pdf-generator with wkhtmltopdf failing

I am trying to generate a pdf using

GitHub - gutschilla/elixir-pdf-generator: Create PDFs with wkhtmltopdf or puppeteer/chromium from Elixir.

. I have installed wkhtmltopdf.

pdf_path_1 = PdfGenerator.generate "<html><body><h1>Boom</h1></body></html>"

Even when tying this command. I am getting the following error:

[debug] {"/usr/local/bin/wkhtmltopdf", ["--page-size", "A4", "/var/folders/32/8jq7kk7s2l3186b1k9cmj5m80000gp/T/DiWc2B0B.html", "/var/folders/32/8jq7kk7s2l3186b1k9cmj5m80000gp/T/DiWc2B0B.pdf"]}
{:error, {:generator_failed, ""}}

Please help.

Have you tried manually running the command in your terminal? There should be more details available that way.

“The command failed” does not give anyone anything to work with.

Hey @dimitarvp ,
First of all thanks for looking into it.

I tried the following command in terminal:

wkhtmltopdf --help

zsh: bad CPU type in executable: wkhtmltopdf

wkhtmltopdf version installed: wkhtmltox-0.12.6-1.macos-cocoa.pkg
MAC OS: macOS Monterey 12.6 installed.

The issue has been solved. After looking into the issue, I found out that it is because of the MacOS chip support. wkhtmltopdf is supported for intel chips only and not m1, so I had to install Rosetta.

softwareupdate --install-rosetta

This post really helped me: MacOS - wkhtmltopdf issue - bad CPU type in executable: wkhtmltopdf

2 Likes