Print Format Getting Error even im using Text file

Traceback (most recent call last):
File “apps/frappe/frappe/utils/pdf.py”, line 90, in get_pdf
filedata = pdfkit.from_string(html, options=options or {}, verbose=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “env/lib/python3.12/site-packages/pdfkit/api.py”, line 75, in from_string
return r.to_pdf(output_path)
^^^^^^^^^^^^^^^^^^^^^
File “env/lib/python3.12/site-packages/pdfkit/pdfkit.py”, line 201, in to_pdf
self.handle_error(exit_code, stderr)
File “env/lib/python3.12/site-packages/pdfkit/pdfkit.py”, line 155, in handle_error
raise IOError(‘wkhtmltopdf reported an error:\n’ + stderr)
OSError: wkhtmltopdf reported an error:
The switch --print-media-type, is not support using unpatched qt, and will be ignored.The switch --header-html, is not support using unpatched qt, and will be ignored.The switch --footer-html, is not support using unpatched qt, and will be ignored.The switch --disable-smart-shrinking, is not support using unpatched qt, and will be ignored.QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to ‘/tmp/runtime-prosworld’
Fontconfig error: No writable cache directories
Exit with code 1 due to network error: ContentNotFoundError

During handling of the above exception, another exception occurred:

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 1778, 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 2194, 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 655, in throw
msgprint(
File “apps/frappe/frappe/init.py”, line 620, in msgprint
_raise_exception()
File “apps/frappe/frappe/init.py”, line 571, in _raise_exception
raise exc
frappe.exceptions.ValidationError: PDF generation failed because of broken image links

@Galaxy_Lab is it custom print format or standard? If it is a custom print format kindly post your code.

Hi,

It may help to describe the operating environment.

May we know the output of wkhtmltopdf -V ?

It is not custom format
i set it as standard

i used each clock seprate html code
for example invoice Header

    <div class="header-row">
        <!-- Left Column: Logo and Address -->
        <div class="header-column logo-section">
<img src=" /files/Pw.png" alt="Company Logo" class="logo">
            <p class="address">{{ doc.company_address_display }}</p>
        </div>
        
        <!-- Right Column: Company Name and Slogan -->
        <div class="header-column right-column">
            <p class="company-name">{{ doc.company }}</p>
            <p class="slogan">Dream It. Believe It. Build It.</p>
        </div>
    </div>
</div>

<hr>

<!-- Invoice Title -->
<div class="title">CLIENT INVOICE</div>

<style>
    .header {
        width: 100%;
        margin-bottom: 10px;
    }

    .header-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .header-column {
        flex: 1;
        padding: 10px;
    }

    .logo-section {
        text-align: left;
        max-width: 40%;
    }

    .right-column {
        text-align: right;
        max-width: 40%;
    }

    .logo {
        width: 200px;
        height: auto;
    }

    .address {
        font-size: 14px;
        color: #333;
        line-height: 1.4;
    }

    .company-name {
        font-size: 20px;
        font-weight: bold;
        color: #333;
        margin: 0;
    }

    .slogan {
        font-size: 16px;
        font-weight: bold;
        color: red;
        margin: 0;
    }

    hr {
        border: 0;
        border-top: 1px solid #ddd;
        margin: 20px 0;
    }

    .title {
        text-align: center;
        font-size: 16px;
        font-weight: bold;
        margin: 30px 0 15px;
    }
</style>

wkhtmltopdf 0.12.6.1 (with patched qt)

What is the path to the file?

See lasalesi’s suggestion here:

https://discuss.frappe.io/t/wkhtmltopdf-layout-error/33493/3

@Galaxy_Lab it seems link problem for the image. pls try giving full address. like below
<img src="https://www.example.com/files/Pw.png" alt="Company Logo" class="logo">

i also tried this but nothing happened

site_config.json

and added the “host_name” doamin,name

its working

thanks for your effort and contribution