Score:0

Wkhtmltopdf fixed header/footer options print extra blank pages. How to debug and fix?

us flag

So for this I am using entity print 2.2.0 with WKHTML 0.12.6 wit these patches:

            "drupal/entity_print": {
            "Add Export to Word Support": "https://www.drupal.org/files/issues/2019-11-22/2733781-47.patch",
            "Adding page numbers in footer in pdf": "https://www.drupal.org/files/issues/2020-05-29/entity_print-custom_footer-2823430-7.patch"
        }

The second one allows for a creation of a hook to add extra options and I have this:

function mymodule_print_pdf_wkhtmltopdf_options_alter(&$options) { 
  $print_dir = '/Users/user/Sites/localhost/d8/web/print';
  $header = $print_dir.'/header.html';
  $footer = $print_dir.'/footer.html';
  $options['header-html'] = $header;
  $options['footer-html'] = $footer;
  $options['enable-local-file-access'] = [$header, $footer];
}

This applies a header and footer to every page but adds two extra empty pages and the first one has two headers. The module debug route skips these options so how do I go about debugging this?

And I did try this with dompdf. It is easier, but unfortunately it doesn't support rtl.

Note: A downgrade to wkhtmltopdf 0.12.5 and doing away with the 'enable-local-file-access' is one fix.

leymannx avatar
ne flag
Where has `$print_dir` been defined/set?
Jed_BH avatar
us flag
Maybe I shouldn't have omitted it. the files are located in a folder named print right under /web directory.
Jed_BH avatar
us flag
I added a definition for it.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.