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

RuntimeError on PDf Generation #1113

Open
mcieaaka opened this issue Apr 24, 2024 · 1 comment
Open

RuntimeError on PDf Generation #1113

mcieaaka opened this issue Apr 24, 2024 · 1 comment

Comments

@mcieaaka
Copy link

Can anybody help me to figure out, Why am I facing this issue, and what might be the fix for the same?

Issue description

While trying to generate PDF in my Rails App, I randomly get this error, but unable to recreate or figure out why this is happening

Here is the error:

Failed to execute:
["/usr/local/bundle/bin/wkhtmltopdf", "--encoding", "UTF-8", "--enable-local-file-access", "--margin-bottom", "4", "--margin-left", "0", "--margin-right", "0", "--header-html", "file:////tmp/wicked_header_pdf20240423-3535-73r70r.html", "--footer-html", "file:////tmp/wicked_footer_pdf20240423-3535-vhx6uw.html", "file:////tmp/wicked_pdf20240423-3535-4x7ecq.html", "/tmp/wicked_pdf_generated_file20240423-3535-6n8vuc.pdf"]
Error: PDF could not be generated!
 Command Error: Loading pages (1/6)
[>                                                           ] 0%
[======>                                                     ] 10%
Error: Failed to load file:////tmp/wicked_header_pdf20240423-3535-73r70r.html, with network status code 203 and http status code 0 - Error opening //tmp/wicked_header_pdf20240423-3535-73r70r.html: No such file or directory
Error: Failed loading page file:////tmp/wicked_header_pdf20240423-3535-73r70r.html (sometimes it will work just to ignore this error with --load-error-handling ignore)
Exit with code 1 due to network error: ContentNotFoundError

Before this, I was getting same error, but the message included: "Blocked Access", I tried adding --enable-local-file-access after which I am getting this new error.

System specifications

wicked_pdf gem version:
2.6.3

whtmltopdf provider gem and version if one is used:
https://rubygems.org/gems/wkhtmltopdf-binary
0.12.6

platform/distribution and version:
Ubuntu 20.04

@unixmonkey
Copy link
Collaborator

Error opening //tmp/wicked_header_pdf20240423-3535-73r70r.html: No such file or directory

Either your TMP directory is becoming non-writable at times, or something is clearing out tmp files before the process that needs them is done.

Do you have a recurring job or deploy process that empties the tmp dir?

Are you holding a separate reference to the header from one PDF generation, and trying to use it for a second one?

Sorry I don't have an answer on this. I'm just hoping maybe I can help you figure out what's happening on your end.

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

No branches or pull requests

2 participants