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
Request page PDF generation broken #6435
Comments
On the Alaveteli staging deployment its possible to download a request page ZIP which contains a PDF. So why does this work and can we get fixed without overhauling the PDF generation? On the server the:
Locally on my Mac:
So the server version doesn't include the breaking change which blocks local filesystem access by default which got introduced with 0.12.6. So this will only be an issue once we upgrade the package /cc @sagepe The staging site is current set the AtEU theme, I wonder if there is something in the WDTK theme which causes some output to stdout and prevents the PDF from being generated. This might get fixed by #6432 but first I'll attempt to replicate the issue by switching staging to the WDTK theme. |
With staging running WDTK theme is still is able to generate PDFs. I have attempted to use WDTK production console to get the HTML source: c = RequestController.new
c.instance_variable_set :@info_request, InfoRequest.find_by(url_title: '...')
c.instance_variable_set :@render_to_file, true
c.request = ActionDispatch::Request.new("rack.input" => "")
c.instance_variable_set :@locales, { :current => AlaveteliLocalization.locale, :available => [] }
c.action_name = 'show'
File.write 'tmp/pdf_source.html', c.render_to_string(template: 'request/show') Running this through
|
The |
The other |
The elements with the |
On staging my user account had dismissed the popup site banner so the issue with When removing my dismissal This fix could be as simple as: diff --git a/app/views/layouts/default.html.erb b/app/views/layouts/default.html.erb
index 04c9bbd12..057b8cd95 100644
--- a/app/views/layouts/default.html.erb
+++ b/app/views/layouts/default.html.erb
@@ -52,11 +52,13 @@
<div class="entirebody">
<a href="#content" class="show-with-keyboard-focus-only skip-to-link" tabindex="0">Skip to content</a>
+ <% unless @render_to_string %>
<!-- begin popups -->
<%= render 'general/site_wide_announcement' if site_wide_announcement.present? %>
<div id="country-message">
</div>
<!-- end popups -->
+ <% end %>
<%= render :partial => 'general/responsive_header' %>
@@ -81,6 +83,7 @@
<%= render :partial => 'general/responsive_footer' %>
</div>
+ <% unless @render_to_string %>
<%= render partial: 'ga_code' unless @user&.is_admin? %>
<%= javascript_include_tag "application" %>
@@ -109,6 +112,7 @@
</script>
<% end %>
<%= content_for :javascript %>
+ <% end %>
<%= render :partial => 'general/before_body_end' %>
|
We need to remove the popup due to WDTK theme using opacity CSS selector for these elements this is causing the wkhtmltopdf-static command to seg fault: > QPixmap: Cannot create a QPixmap when no GUI is being used > ... > Segmentation fault Also need to remove JS from the page as this causes SSL socket errors: > QSslSocket: cannot resolve ... > QSslSocket: cannot call unresolved function ... Fixes #6435
Deployed, moved aside the previously cached PDFs and the confirmed the PDF generation now works 🎉 |
For macOS user we can install v0.11.0 rc1 of I'll open a ticket for supporting v0.12.x |
We're unable to generate PDFs of the request page when generating request zip downloads.
There seems to be several issues effecting this which have been hidden to us due to Alaveteli transparently falling back to a txt only request page.
The default command is
wkhtmltopdf
.The first issue seemed to stem from the command output. Alaveteli assumes the command shouldn't output anything to stdout, if it does then it has failed.
alaveteli/app/controllers/request_controller.rb
Lines 680 to 686 in a787d6e
This appears to be an upstream change in the command. We attempted to fix this by adding the
-q
quiet command flag to limit output: #6257This isn't ideal and means re-users couldn't specify there preferred alternative to
wkhtmltopdf
.Also we really we shouldn't assume success/failure based on if there was output or not. We have tarting looking at refactoring
AlaveteliExternalCommand
so we catch errors in a better way: #6432During this latest refactoring, we actually got
wkhtmltopdf
command to run but it would still warn and error with output like:The requests for
about:blank
come from howwkhtmltopdf
now works. By default in v 0.12.6 it will block local file access and any requests to local files now gets redirected toabout:blank
. This is erroring due to theabout
protocol not being handled wkhtmltopdf/wkhtmltopdf#4460, there is a unmerged PR to address this wkhtmltopdf/wkhtmltopdf#5031.To get around this people seem to be passing the
--enable-local-file-access
command flag but there could be security concerns with this approach. Personally I feel uneasy out using this flag.As a test I enabled local file access but there are still more problems:
It looks like we need to ensure there won't be any local file access at all. There are some other flags (
--no-images
,--disable-javascript
,--print-media-type
, ...) which might help us generate PDFs.The text was updated successfully, but these errors were encountered: