Bonjour,
On a des problèmes avec le rendu des pdf avec wkgtmltopdf
Savez vous si il est déjà possible d’utiliser l’autre générateur mentionné dans ce post ?
Hi everyone, I would like to raise a concern regarding the PDF generation engine currently used in Frappe/ERPNext — wkhtmltopdf. As many of you probably know, wkhtmltopdf has been obsolete for years. It has not received meaningful updates or...
Reading time: 1 mins 🕑
Likes: 3 ❤
Merci à vous,
Bonjour @Gauthier ,
Un hook a déjà été ajouté dans Frappe (Dodock v4) pour que l’application Print Designer puisse imprimer avec Chrome (feat: Chrome PDF Generator by maharshivpatel · Pull Request #399 · frappe/print_designer · GitHub ). Il faut installer Print Designer pour pouvoir l’utiliser.
Attention la configuration des formats d’impression via Print Designer ne fonctionne qu’avec Chromium/Google Chrome (Pas Firefox ou Safari, sinon ça casse les formats d’impression).
Le sujet a l’air d’être sur la table depuis quelques temps côté Frappe, mais je ne sais pas du tout quand ça sera priorisé (New print backend: puppeteer · Issue #25831 · frappe/frappe · GitHub ).
Sinon, pour le moment, la seule solution est de faire sa propre implémentation de moteur d’impression.
Quel type de problèmes rencontrez-vous avec wkhtmltopdf ?
1 « J'aime »
Bonjour Charles-Henri
Le souci c’est des sauts de pages entre les lignes d’un tableau (malgré qu’on ait coché l’option dans les paramètres d’impression et des essais de css personnalisé)
Merci, j’ai ajouté print designer et activé l’impression avec chrome
Ca a corrigé nos problèmes de saut de page mais en voulant envoyer un email pour tester on a cette erreur pour l’instant
opened 12:27PM - 11 Jul 25 UTC
**Description:**
We're using the latest `develop` branch of Frappe and `print_d… esigner` with the new **Chrome PDF Generator** as the backend (set via the Print Format configuration).
When sending a Sales Invoice via email with “Attach Print” enabled, the system fails with a `RuntimeError: object is not bound`. This happens specifically when the PDF is being generated using the Chrome backend.
**Stacktrace Summary:**
```text
RuntimeError: object is not bound
Traceback:
File ".../frappe/email/doctype/email_queue/email_queue.py", line 398, in include_attachments
print_format_file = frappe.attach_print(**attachment)
File ".../frappe/utils/print_utils.py", line 77, in get_print
pdf = frappe.call(...)
File ".../print_designer/pdf_generator/browser.py", line 416, in _open_header_footer_pages
self.footer_page.set_tab_url(frappe.request.host_url)
File ".../werkzeug/local.py", line 501, in _get_current_object
raise RuntimeError(unbound_message) from None
```
**Analysis:**
Looks like `frappe.request` is being accessed in a background job (email queue processing), where the request context is not available. This is not safe outside web request contexts. Specifically:
```python
self.footer_page.set_tab_url(frappe.request.host_url)
```
This line is trying to access `frappe.request.host_url` inside the `Browser` class when generating the header/footer, but `frappe.request` doesn’t exist in a non-request context like a background job.
**Steps to Reproduce:**
1. Create a Print Format and set PDF Generator to "chrome".
2. Enable header/footer (footer used in my case).
3. Send a Sales Invoice using Email with "Attach Print" checked.
4. Error occurs and email fails to send.
**Environment:**
* Frappe version: 15.71.0 (version-15)
* ERPNext version: 15.65.2 (version-15)
* Print Designer version: 1.x.x-develop (develop)
```
Traceback (most recent call last):
File "apps/frappe/frappe/email/queue.py", line 150, in flush
email_queue.send()
File "apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 173, in send
message = ctx.build_message(recipient.recipient)
File "apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 321, in build_message
message = self.include_attachments(message)
File "apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 398, in include_attachments
print_format_file = frappe.attach_print(**attachment)
File "apps/frappe/frappe/__init__.py", line 2165, in attach_print
else get_print(doctype, name, **kwargs)
File "apps/frappe/frappe/utils/print_utils.py", line 77, in get_print
pdf = frappe.call(...)
File "apps/frappe/frappe/__init__.py", line 1751, in call
return fn(*args, **newargs)
File "apps/print_designer/print_designer/pdf.py", line 146, in wrapper
result = func(*args, **kwargs)
File "apps/print_designer/print_designer/pdf_generator/pdf.py", line 43, in get_pdf
browser = Browser(generator, print_format, html, options)
File "apps/print_designer/print_designer/pdf_generator/browser.py", line 29, in __init__
self.prepare_header_footer()
File "apps/print_designer/print_designer/pdf_generator/browser.py", line 133, in prepare_header_footer
self._open_header_footer_pages()
File "apps/print_designer/print_designer/pdf_generator/browser.py", line 416, in _open_header_footer_pages
self.footer_page.set_tab_url(frappe.request.host_url)
File "env/lib64/python3.12/site-packages/werkzeug/local.py", line 501, in _get_current_object
raise RuntimeError('object is not bound') from None
RuntimeError: object is not bound
```
En attente d’un correctif de leur part du coup
2 « J'aime »
Effectivement il y a un bug dans le cas d’un envoi d’email (ou d’une autre opération en tâche de fond). C’était plutôt simple à régler donc j’ai proposé un correctif, il ne reste qu’à attendre qu’ils l’appliquent :
frappe:develop
← cogk:fix-host-url-when-printing-outside-request
opened 01:43PM - 18 Jul 25 UTC
Corentin
3 « J'aime »