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

Fix PDF request summary #6257

Closed
wants to merge 2 commits into from
Closed

Fix PDF request summary #6257

wants to merge 2 commits into from

Conversation

gbp
Copy link
Member

@gbp gbp commented May 18, 2021

Relevant issue(s)

Connected to #6056

What does this do?

Add -q option to calls to wkhtmltopdf

This makes the wkhtmltopdf command less verbose which is important as we check for output to determine if the command was successful or not.

Really should be checking the exit code but this would mean a change in the AlaveteliExternalCommand module which is also used else where.

Why was this needed?

This is broken in production and only txt correspondence is being downloaded. Not sure when this broken possiblly related to https://github.com/mysociety/sysadmin/issues/867

gbp added 2 commits May 18, 2021 12:03
This makes the wkhtmltopdf command less verbose which is important as we
check for output to determine if the command was successful or not.

Really should be checking the exit code but this would mean a change in
the AlaveteliExternalCommand module which is also used else where.
@@ -678,13 +678,18 @@ def make_request_summary_file(info_request)
tmp_input.write(html_output)
tmp_input.close
tmp_output = Tempfile.new('foihtml2pdf-output')
output = AlaveteliExternalCommand.run(convert_command, tmp_input.path, tmp_output.path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we could make this work by changing the convert_command to preserve the interface here.

# config/general.yml
HTML_TO_PDF_COMMAND: "/usr/local/bin/wkhtmltopdf -q"

If this works then we'll want to update config/general.yml-example so that it gets set like this for everyone, and also note in the changelog that this is needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work without additional changes as this would eval to false:

convert_command = AlaveteliConfiguration.html_to_pdf_command
File.exist?(convert_command)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about something like:

# Default
HTML_TO_PDF_COMMAND: "/usr/local/bin/wkhtmltopdf"

# Optional
HTML_TO_PDF_COMMAND: ["/usr/local/bin/wkhtmltopdf", "-q"]
convert_command = Array(AlaveteliConfiguration.html_to_pdf_command)
cmd = convert_command.shift
File.exist?(cmd)
output = AlaveteliExternalCommand.run(cmd, convert_command, tmp_input.path, tmp_output.path)

@garethrees
Copy link
Member

Superseded by #6488?

@gbp gbp closed this Sep 27, 2021
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

Successfully merging this pull request may close these issues.

None yet

2 participants