-
Notifications
You must be signed in to change notification settings - Fork 40
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
Missing images when batch printing PDFs #339
Comments
Hi @ccapndave, how do you reference the images? Are they coming from local or remote network? In our experience it is the safest to inline as much as you can with base64 data urls, since then chrome doesn't need extra requests at all and the content is already there when rendering the page ( https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Schemes/data Is that an option for you? |
Thanks for the quick response! Everything (the CSS and the background images inside the CSS) are loaded using an absolute URL, but actually DNS should resolve it back to the same server that is running Chromic. However, everything sits behind a load balancer so maybe there is a brief delay. Using base64 urls could be an option, but it would involve rewriting a lot of templates. As a temporary workaround is there a way to add a delay of 1 second before the PDF is printed? I expect this would fix the problem until we can do it properly. |
You can evaluate JS before loading: Maybe chrome does not wait on background images, since they are not considered to be part of the content for the Apparently one can wait on images like so: I also found a gist using this technique for selenium. Maybe this can serve as an inspiration for you: Probably better to wait for the images instead of a flat 1 second delay, to be sure they are always there, even under high load. |
Thanks very much for the advice! I'll try these out and let you know how I get on. |
Hey! Thanks for such an amazing library :)
We've recently noticed that sometimes our PDF generation are randomly missing some background images. It only seems to happens if we are batch generating a bunch of PDFs together, and the missing images are different each time
I get the impression that in this case the background images have not fully loaded when then PDF is printed.
We are using
{:html: html}
to define the input like so:I did read a comment on another issue that injecting html from a string can be a bit flaky but unfortunately we don't have a choice for our use case.
Any advice on how to debug this would be gratefully received!
The text was updated successfully, but these errors were encountered: