Open robbieaverill opened 6 years ago
Ok, it's not the piping to stdout that's the issue but looks like an error in wkhtmltopdf caused by having certain kinds of content in the HTML. We're not the only ones! See https://github.com/wkhtmltopdf/wkhtmltopdf/issues/2051. Updated title to reflect this change.
The cause is one or more of the following:
<script src="//jquery.cdn.com/whatever.js">
- very common<script src="http://mysite.com/javascript.js?m=1u983243">
- SS framework adds this to resources by defaultWe can "fix" the first two points with string manipulation, but we can't do anything about broken links in the page. It looks like a combination of one or more of those things causes the PDF generation to fail with an error message on the first attempt. It still generates a PDF but there's no guarantee that it would look the same as you'd expect it to.
I don't think we can fix this problem. There's 70 others on this GitHub issue complaining about the same problem, and it hasn't been acknowledged or fixed in 3 years so I don't expect it will be. https://github.com/wkhtmltopdf/wkhtmltopdf/issues/2051
Our options:
Further - regression tested against CWP 1.x:
Since it affects the CWP 1.x equivalent code as well, I'm going to reduce the impact slightly and treat it as non-blocking for release. This affects script and stylesheet references that don't exist, but we should be able to expect a lower number of these, since they're generally critical for a website to function. 404s in content would be more concerning, but that's not a problem.
For clarity, the affects/v3
label refers to the same functionality in the cwp/cwp module
From #1:
Noted issue: clicking the "Export to PDF" link for a page initially fails with this message:
Subsequent requests succeed and open the PDF.
I suspect this could be a macOS issue with piping the wkhtmltopdf output to stdout. We could write it to the PHP temp dir instead of piping to stdout.
To reproduce:
You can clear the PDF generated on initial load via
vendor/bin/sake dev/tasks/CleanupGeneratedPdfBuildTask
which will allow you to continue to reproduce the initial PDF export page load with the error, while running this task afterwards each time.