I have made a label using HTML and CSS and previewed the file on my IDE but when I import the HTML and CSS files to the ERP and preview the print format it looks noticeably different. For one, the line spacing is not the same as my IDE preview. Does anyone know how I can stop the ERPNext from changing the look of my label?
snv
December 27, 2022, 3:06pm
2
Hello,
You can use inspect element to identify ERPNext overrides:
You can then look at the problematic ERPNext rules and use either specific CSS rules or !important
to prevent override:
html, css, css-selectors
Note that the PDF might still look different, since the underlying PDF engine wkhtmltopdf
doesn’t support some CSS properties.
Thank you for the response! Do you know of a way I can just quickly remove all of the ERPNext overrides?
snv
December 27, 2022, 3:34pm
4
Frappe Framework seems to always include:
<!DOCTYPE html>
<html lang="{{ lang }}" dir="{{ layout_direction }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ title }}</title>
<meta name="generator" content="frappe">
{{ include_style('print.bundle.css') }}
{% if print_style %}
<style>
{{ print_style }}
</style>
{% endif %}
</head>
<body>
<div class="action-banner print-hide">
<a class="p-2" onclick="window.print();">
{{ _("Print") }}
if not style:
style = print_settings.print_style or ""
context = {
"print_settings": print_settings,
"print_style": style,
"font": get_font(print_settings, print_format, for_legacy),
}
css = frappe.get_template("templates/styles/standard.css").render(context)
if style and frappe.db.exists("Print Style", style):
css = css + "\n" + frappe.db.get_value("Print Style", style, "css")
# move @import to top
for at_import in list(set(re.findall(r"(@import url\([^\)]+\)[;]?)", css))):
css = css.replace(at_import, "")
# prepend css with at_import
css = at_import + css
You can still remove these if you really want to, but I can’t think of a quick way .
Thank you for the quick responses! Do you know how I would go about removing these?