@@ -409,19 +409,14 @@ frappe.ui.form.PrintView = class { | |||||
setup_print_format_dom(out, $print_format) { | setup_print_format_dom(out, $print_format) { | ||||
this.print_wrapper.find('.print-format-skeleton').remove(); | this.print_wrapper.find('.print-format-skeleton').remove(); | ||||
let base_url = frappe.urllib.get_base_url(); | let base_url = frappe.urllib.get_base_url(); | ||||
let print_css = frappe.assets.bundled_asset('print.bundle.css'); | |||||
let print_css = frappe.assets.bundled_asset('print.bundle.css', frappe.utils.is_rtl(this.lang_code)); | |||||
this.$print_format_body.find('html').attr('dir', frappe.utils.is_rtl(this.lang_code) ? 'rtl': 'ltr'); | |||||
this.$print_format_body.find('html').attr('lang', this.lang_code); | |||||
this.$print_format_body.find('head').html( | this.$print_format_body.find('head').html( | ||||
`<style type="text/css">${out.style}</style> | `<style type="text/css">${out.style}</style> | ||||
<link href="${base_url}${print_css}" rel="stylesheet">` | <link href="${base_url}${print_css}" rel="stylesheet">` | ||||
); | ); | ||||
if (frappe.utils.is_rtl(this.lang_code)) { | |||||
let rtl_css = frappe.assets.bundled_asset('frappe-rtl.bundle.css'); | |||||
this.$print_format_body.find('head').append( | |||||
`<link type="text/css" rel="stylesheet" href="${base_url}${rtl_css}"></link>` | |||||
); | |||||
} | |||||
this.$print_format_body.find('body').html( | this.$print_format_body.find('body').html( | ||||
`<div class="print-format print-format-preview">${out.html}</div>` | `<div class="print-format print-format-preview">${out.html}</div>` | ||||
); | ); | ||||
@@ -1,5 +1,5 @@ | |||||
<!DOCTYPE html> | <!DOCTYPE html> | ||||
<html lang="en"> | |||||
<html lang="en" dir="{{ layout_direction }}"> | |||||
<head> | <head> | ||||
<meta charset="utf-8"> | <meta charset="utf-8"> | ||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||||
@@ -1264,7 +1264,9 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList { | |||||
print_css: print_css, | print_css: print_css, | ||||
print_settings: print_settings, | print_settings: print_settings, | ||||
landscape: landscape, | landscape: landscape, | ||||
columns: columns | |||||
columns: columns, | |||||
lang: frappe.boot.lang, | |||||
layout_direction: frappe.utils.is_rtl() ? "rtl" : "ltr" | |||||
}); | }); | ||||
frappe.render_pdf(html, print_settings); | frappe.render_pdf(html, print_settings); | ||||
@@ -1,5 +1,5 @@ | |||||
<!DOCTYPE html> | <!DOCTYPE html> | ||||
<html lang="en"> | |||||
<html lang="{{ lang }}" dir="{{ layout_direction }}"> | |||||
<head> | <head> | ||||
<meta charset="utf-8"> | <meta charset="utf-8"> | ||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||||
@@ -7,6 +7,7 @@ from frappe import _ | |||||
from frappe.modules import get_doc_path | from frappe.modules import get_doc_path | ||||
from frappe.core.doctype.access_log.access_log import make_access_log | from frappe.core.doctype.access_log.access_log import make_access_log | ||||
from frappe.utils import cint, sanitize_html, strip_html | from frappe.utils import cint, sanitize_html, strip_html | ||||
from frappe.utils.jinja_globals import is_rtl | |||||
no_cache = 1 | no_cache = 1 | ||||
@@ -44,7 +45,8 @@ def get_context(context): | |||||
"css": get_print_style(frappe.form_dict.style, print_format), | "css": get_print_style(frappe.form_dict.style, print_format), | ||||
"comment": frappe.session.user, | "comment": frappe.session.user, | ||||
"title": doc.get(meta.title_field) if meta.title_field else doc.name, | "title": doc.get(meta.title_field) if meta.title_field else doc.name, | ||||
"has_rtl": True if frappe.local.lang in ["ar", "he", "fa", "ps"] else False | |||||
"lang": frappe.local.lang, | |||||
"layout_direction": "rtl" if is_rtl() else "ltr" | |||||
} | } | ||||
def get_print_format_doc(print_format_name, meta): | def get_print_format_doc(print_format_name, meta): | ||||