Public link to View this in browser

I would like to obtain a PDF link that allows customers to view and verify it online, similar to how ERPNext sends links via email. However, when using the provided HTML snippet in the print format, an error message stating “invalid key” is generated. Could you please assist me in identifying where I may have gone wrong?

{% set token = frappe.utils.generate_hash(length=16) %}
{% set base_url = frappe.utils.get_url() %}
{% set signed_url = base_url + "/printview?doctype=Sales%20Invoice&name=" + doc.name + "&key=" + token %}

<a href="{{ signed_url }}" target="_blank">View Invoice</a>
1 Like

Any Solution?