frappe / frappe

Low code web framework for real world applications, in Python and Javascript
https://frappeframework.com
MIT License
7.26k stars 3.45k forks source link

PDF generation failed because of broken image links - Print Format Errors, etc #27964

Open edardev opened 1 month ago

edardev commented 1 month ago

I am encountering several errors when trying to submit or print documents. The most common error message I receive is:

image

In addition, print formats are not functioning as expected. These issues occur frequently during various operations across both Frappe and ERPNext apps, making it difficult to complete tasks that involve printing.

image

Steps to reproduce the issue Submit a document or attempt to print any standard document (e.g., Sales Invoice, Purchase Order). Error message "PDF generation failed because of broken image links" appears. Print formats fail, leading to either broken layouts or incomplete documents. Observed result PDF generation fails with broken image links. Print formats do not render correctly, causing errors during the printing process.

Expected result The system should generate PDFs without broken images, and the print formats should work without errors across all operations.

Stacktrace / full error message

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 114, in application
    response = frappe.api.handle(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/__init__.py", line 49, in handle
    data = endpoint(**arguments)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
    return frappe.handler.handle()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 49, in handle
    data = execute_cmd(cmd)
           ^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1775, in call
    return fn(*args, **newargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/print_format.py", line 234, in download_pdf
    pdf_file = frappe.get_print(
               ^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 2191, in get_print
    return get_pdf(html, options=pdf_options, output=output) if as_pdf else html
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/pdf.py", line 98, in get_pdf
    frappe.throw(_("PDF generation failed because of broken image links"))
  File "apps/frappe/frappe/__init__.py", line 652, in throw
    msgprint(
  File "apps/frappe/frappe/__init__.py", line 617, in msgprint
    _raise_exception()
  File "apps/frappe/frappe/__init__.py", line 568, in _raise_exception
    raise exc
frappe.exceptions.ValidationError: PDF generation failed because of broken image links

During handling of the above exception, another exception occurred:

Extra printing button not working either. image

maheini commented 1 month ago

I'd expect a system-related issue... in order to solve this, more information is required. This error is an OS error, caused by pypdf or pdfkit library.

Can you tell us more about your env and print?

edardev commented 1 month ago

I'd expect a system-related issue... in order to solve this, more information is required. This error is an OS error, caused by pypdf or pdfkit library.

Can you tell us more about your env and print?

  • OS & version
  • docker? cloud?
  • pypdf & pdfkit version
  • Print format/ print format code
  • Does this happen to all print formats and doctypes? even the default print format?

I am using the same specifications from the frappe/frappe_docker repository for both the default frappe/erpnext image and my custom images. Despite this, I'm still encountering printing issues everywhere and unformatted print formats etc.

maheini commented 1 month ago

Ok, that's a good approach to begin with 😃 Is there more you can share about your system in order to get more details about print formats, lib versions e.g.?

edardev commented 1 month ago

rint formats, lib versions e.g.?

Sure! Here’s more information about my environment and the printing issues:

OS & Version: I am using the official frappe/erpnext and/or custom docker images: ARG DEBIAN_BASE=bookworm FROM python:${PYTHON_VERSION}-slim-${DEBIAN_BASE} AS base

Let me know if there’s anything else I can provide to help troubleshoot this issue!

ARG PYTHON_VERSION=3.11.6 ARG DEBIAN_BASE=bookworm FROM python:${PYTHON_VERSION}-slim-${DEBIAN_BASE} AS base ARG WKHTMLTOPDF_VERSION=0.12.6.1-3 ARG WKHTMLTOPDF_DISTRO=bookworm ARG NODE_VERSION=18.18.2

image