Setting wkhtmltopdf / PDFKit options via custom print format

Hello,

as discussed here its neccessary to set some options to wkhtmltopdf for printing a background borderless in the pdf output:

In my case i could achive this with setting the margins to 0 hardcoded in:

frappe-bench/apps/frappe/frappe/utils/pdf.py in the prepare_options function as defaults like:

‘margin-right’: ‘0mm’,
‘margin-left’: ‘0mm’,
‘margin-top’: ‘0mm’,
‘margin-bottom’: ‘0mm’,

But there is as function called read_options_from_html in the same file which looks for html tags in the delivered html-data, so i think one should be able to pass those options from a custom print format. Could someone tell me, how this is intended to be used?

Thanks in advance.

Printing ID Card,
Borderless custom size

1 Like

I believe it was described with more detail when the feature was added, can’t seem to find that post. You can add something like this to a print format.

<div id="variables" style="display: none;"><span id="margin-bottom">25mm</span><span id="margin-top">25mm</span></div>

That actually works.

Thank you!