Comments (11)
Having same error here, without enable_local_file_access
option, with no local file access, resulting blocked file access error.
I am currently doubting S3 bucket request rate exceeding.
from wicked_pdf.
Does reverting solve your problem? Did you also upgrade wkhtmltopdf
at the same time? If you did, I would bet that's the real cause.
Something I've always tried to do is make sure my assets are always local files before PDF generation, and nothing is being fetched over the network in real-time.
from wicked_pdf.
Any update on this? Would an update to 2.7.0 or 2.8.0 fix this?
from wicked_pdf.
@staffler-xyz Possibly, but probably not. Have you tried yet?
Please provide more information if you can. What is the actual error? Do you get a stacktrace? What version are you running? Is it also random (like it works most of the time)?
I can't think of any good reason this happens randomly, unless your system is getting rid of tempfiles that are still in-use, or you have system limits that prevent too many wkhtmltopdf
instances from running simultaneously.
from wicked_pdf.
hi, I get this error:
["/app/vendor/bundle/ruby/3.1.0/gems/wkhtmltopdf-heroku-2.12.6.0/bin/wkhtmltopdf-linux-amd64", "--disable-smart-shrinking", "--margin-top", "0", "--margin-bottom", "0", "--margin-left", "0", "--margin-right", "0", "--footer-spacing", "-30", "--footer-html", "file:////tmp/wicked_footer_pdf20240315-2-pag8lr.html", "file:////tmp/wicked_pdf20240315-2-gicnwn.html", "/tmp/wicked_pdf_generated_file20240315-2-1mghdn.pdf"]
Error: PDF could not be generated!
Command Error: Loading pages (1/6)
[> ] 0%
[======> ] 10%
[=======================> ] 39%
[=========================> ] 43%
[===========================> ] 45%
[============================> ] 47%
[=============================> ] 49%
[==================================> ] 57%
[=====================================> ] 63%
[=========================================> ] 69%
[=============================================> ] 75%
[================================================> ] 80%
[==================================================> ] 84%
[============================================================] 100%
Counting pages (2/6)
[============================================================] Object 1 of 1
Resolving links (4/6)
[============================================================] Object 1 of 1
Loading headers and footers (5/6)
[> ] 1%
Warning: Blocked access to file
[=&gā¦
(unfortunately the output is truncated at the end)
wicked_pdf gem version (output of cat Gemfile.lock | grep wicked_pdf): wicked_pdf (2.6.3)
wkhtmltopdf version (output of wkhtmltopdf --version): 0.12.6.0
whtmltopdf [provider gem]: wkhtmltopdf-heroku (2.12.6.0)
platform/distribution and version: heroku-20
from wicked_pdf.
@staffler-xyz Does it always die out like this? Is it random, or every time for this specific PDF generation?
This looks like wkhtmltopdf
is dying early on while setting up the headers and footers (which you have), and is also complaining that it can't load a file (which is default behavior in newish versions of wkhtmltopdf, but can be "fixed" by adding enable_local_file_access
as true
to the WickedPDF config.
Try either enabling that option, or disabling custom headers and footers, or some combination of both. Also make sure your footer is a complete and valid HTML document, including doctype and <html><head></head><body>
.
from wicked_pdf.
it happens randomly, usually it works after reloading the page. But it also fails in the background with ActiveJob and WickedPdf.new.pdf_from_string
.
We don't use local files, only images from CDN.
This is our layout (simplified):
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8' />
<%= stylesheet_link_tag("pdf", :media => "all") %>
<style type="text/css">
<%= yield(:styles) %>
</style>
<%= javascript_tag do %>
function number_pages() {
<javascript code>
}
<% end %>
</head>
<body onload="number_pages()">
<%= yield %>
</body>
</html>
I noticed that this might be the problem:
<%= stylesheet_link_tag("pdf", :media => "all") %>
Should it be replaced with:
<%= wicked_pdf_stylesheet_link_tag("pdf", :media => "all") %>
Did anyone solve this successfully?
from wicked_pdf.
Is it possible that generating the PDF is exceeding Heroku's memory limit, and thus getting killed off before it finishes?
from wicked_pdf.
I don't think so, memory is 16GB RAM and the application is running at about 1GB RAM (no spikes when running wkhtmltopdf commands)
from wicked_pdf.
If possible, try downloading remote resources from the CDN into local files or tempfiles or base64, and loading that instead.
This is what I've always done and advocated for, though I'm sure many others do not and it works fine for their use-cases.
I don't have any solid reasons for this, but experience & casually googling wkhtmltopdf dies sometimes
turns up numerous issues, like this one where they needed to increase the JS delay, this one where they suggested it was opening too many files or running out of swap space, or this one where the network stack dies while downloading assets.
from wicked_pdf.
ok, thanks for your hints. I will check again and post the solution here, if found.
from wicked_pdf.
Related Issues (20)
- Add support for --load-error-handling and --load-media-error-handling
- Remote asset returning non-200 response does not trigger an error
- Greek Character "š¼" not showing correctly within PDF generated by Wicked PDF HOT 7
- Images won't load from Active Storage using Amazon S3 Bucket HOT 2
- version 2.7.0 breaks with webpacker
- Content is getting cropped in PDF
- ActionView::Template::Error uninitialized constant WickedPdf::WickedPdfHelper::Assets::SprocketsEnvironment::Sprockets HOT 3
- Feature Request: PDF/A-1
- pdf_from_url CSS not working HOT 1
- Raw PDF being rendered. HOT 1
- OpenStruct causes NameError in Rake13.2.0
- PDF is being rendered with raw ERB code HOT 4
- Content overlaps with the header layout
- RuntimeError on PDf Generation HOT 1
- wicked_pdf due to wkhtmltopdf not finding OpenSSL 1.1 despite installing over OpenSSL 3 HOT 7
- Remove usage of `OpenStruct` or add `ostruct` as dependency
- v2.8.0 causing ActionView::Template::Error: no implicit conversion of nil into String for first time in years HOT 7
- ArgumentError when changing the WickedPdf.config={...} to the new WickedPdf.configure.do |c| ... end HOT 1
- Error: PDF could not be generated! HOT 1
- Public assets not getting loaded after upgrade to Rails 7 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wicked_pdf.