diff --git a/frappe/printing/page/print/print.js b/frappe/printing/page/print/print.js
index f86c0099bb6..05e6d9ee8f8 100644
--- a/frappe/printing/page/print/print.js
+++ b/frappe/printing/page/print/print.js
@@ -603,7 +603,24 @@ frappe.ui.form.PrintView = class {
},
});
}
-
+ async is_wkhtmltopdf_valid() {
+ const is_valid = await frappe.xcall("frappe.utils.pdf.is_wkhtmltopdf_valid");
+ // function returns true or false
+ if (is_valid) return;
+ frappe.msgprint({
+ title: __("Invalid wkhtmltopdf version"),
+ message:
+ __("PDF generation may not work as expected.") +
+ "
" +
+ __("Please contact your system manager to install correct version.") +
+ "
" +
+ __("Correct version :") +
+ " " +
+ __("wkhtmltopdf 0.12.x (with patched qt).") +
+ "",
+ indicator: "red",
+ });
+ }
render_pdf() {
let print_format = this.get_print_format();
if (print_format.print_format_builder_beta) {
@@ -619,6 +636,7 @@ frappe.ui.form.PrintView = class {
return;
}
} else {
+ this.is_wkhtmltopdf_valid();
this.render_page("/api/method/frappe.utils.print_format.download_pdf?");
}
}
diff --git a/frappe/utils/pdf.py b/frappe/utils/pdf.py
index 41bd4c41d12..8b20da19b37 100644
--- a/frappe/utils/pdf.py
+++ b/frappe/utils/pdf.py
@@ -18,6 +18,7 @@
from frappe import _
from frappe.core.doctype.file.utils import find_file_by_url
from frappe.utils import cstr, scrub_urls
+from frappe.utils.caching import redis_cache
from frappe.utils.jinja_globals import bundled_asset, is_rtl
PDF_CONTENT_ERRORS = [
@@ -352,6 +353,16 @@ def toggle_visible_pdf(soup):
tag.extract()
+@frappe.whitelist()
+@redis_cache(ttl=60 * 60)
+def is_wkhtmltopdf_valid():
+ try:
+ output = subprocess.check_output(["wkhtmltopdf", "--version"])
+ return "qt" in output.decode("utf-8").lower()
+ except Exception:
+ return False
+
+
def get_wkhtmltopdf_version():
wkhtmltopdf_version = frappe.cache.hget("wkhtmltopdf_version", None)