gutschilla / elixir-pdf-generator

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

Issue on wkhtmltopdf 0.12.6 #79

Open benonymus opened 3 years ago

benonymus commented 3 years ago

Hey, I updated to wkhtmltopdf 0.12.6 and there seems to be this problem: https://github.com/wkhtmltopdf/wkhtmltopdf/issues/4926 or this https://stackoverflow.com/questions/62315246/wkhtmltopdf-0-12-6-warning-blocked-access-to-file

The solution would be to pass the --enable-local-file-access flag, I tried to pass it as shell params but doesn't seem to work.

How should I pass it?

I am getting after some tweaking:

(MatchError) no match of right hand side value: {:error, {:generator_failed, "Loading page (1/2)\n[> ] 0%\r[==============> ] 24%\r"}}

The original full error is the following:

(MatchError) no match of right hand side value: {:error, {:generator_failed, "QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'\nLoading page (1/2)\n[> ] 0%\r[======================> ] 37%\rWarning: Blocked access to file /tmp/qr_business_order_nEQx8vpXgWDbXAmN.png\nError: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol \"about\" is unknown\n"}}

I fixed the XDG_RUNTIME_DIR part by setting it as an env var, and i fixed the 301 by not writing images to files and loading them, but rather passing them as base64 to the template.

The last piece is the error on the top, that I think the flag could fix, the flag might have fixed it all.

zivaskovic commented 2 years ago

Did someone solved this problem?

{:error, {:generator_failed, "Loading page (1/2)\n[> ] 0%\r[==============================> ] 50%\r"}}
benonymus commented 2 years ago

Hey, I am not sure about the error, but you might want to check out chromic_pdf, I found it easier to work with than wkhtmltopdf based generators.

Get Outlook for iOShttps://aka.ms/o0ukef


From: zivaskovic @.> Sent: Friday, February 11, 2022 4:47:02 PM To: gutschilla/elixir-pdf-generator @.> Cc: Bence Janos Toth @.>; Author @.> Subject: Re: [gutschilla/elixir-pdf-generator] Issue on wkhtmltopdf 0.12.6 (#79)

Did someone solved this problem?

{:error, {:generator_failed, "Loading page (1/2)\n[> ] 0%\r[==============================> ] 50%\r"}}

— Reply to this email directly, view it on GitHubhttps://github.com/gutschilla/elixir-pdf-generator/issues/79#issuecomment-1036030534, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADMN6Q77ZHZI4S6ALTGZDMTU2TLJNANCNFSM4WVZP6QQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you authored the thread.Message ID: @.***>

drKreso commented 2 years ago
apk add ttf-liberation

On Alpine linux helped me. Missing fonts gave segfault.

tfwright commented 2 years ago

Missing fonts gave segfault.

I was getting the same opaque error @zivaskovic mentions and adding the font to my docker file fixed the issue for me as well.