Core broke the implementation for wkhtmltopdf with #1494670: References to CSS, JS, and similar files should be root-relative URLs: avoids mixed content warnings & fewer bytes to send

Dompdf has a setting for providing the base url but I can't find the same setting just yet for wkhtmltopdf. We'll either have to transform the URLs back into absolute URLs in Drupal first or find the appropriate setting.

Comments

benjy created an issue. See original summary.

benjy’s picture

Status: Active » Needs review
StatusFileSize
new2.04 KB

Here we go, temporary workaround to fix the PHPWkhtmltopdf.

Might add some context so we only have to apply this fix for certain implementations. Also, needs tests.

Status: Needs review » Needs work

The last submitted patch, 2: 2671134-2.patch, failed testing.

benjy’s picture

Status: Needs work » Needs review
StatusFileSize
new2.09 KB

Try the HTML5 parser.

Status: Needs review » Needs work

The last submitted patch, 4: 2671134-3.patch, failed testing.

benjy’s picture

Status: Needs work » Needs review
StatusFileSize
new2.2 KB

Again with the right library.

benjy’s picture

StatusFileSize
new2.41 KB

Final patch.

sam152’s picture

Status: Needs review » Needs work
  1. +++ b/entity_print.module
    @@ -92,3 +94,40 @@ function entity_print_form_entity_view_display_edit_form_submit(&$form, FormStat
    +      $href = $node->getAttribute($attribute);
    

    wrong variable name

  2. +++ b/entity_print.module
    @@ -92,3 +94,40 @@ function entity_print_form_entity_view_display_edit_form_submit(&$form, FormStat
    +      if (Unicode::substr($href, 0, 1) === '/') {
    

    Does this account for protocol agnostic URLs? what about something like:

    <img src="//sitename.com/sites/default/files..." />

benjy’s picture

Status: Needs work » Needs review
StatusFileSize
new2.65 KB

Both fixed.

benjy’s picture

Status: Needs review » Reviewed & tested by the community

Will commit this tomorrow.

  • benjy committed a4780e9 on 8.x-1.x
    Issue #2671134 by benjy: PHP Wkhtmltopdf not working
    
benjy’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Hopefully one day i'll be able to remove this code!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.