ERPNext Raw printing Thermal printer issues

Hi i am unable to print in erpnext using raw commands, Can someone help me in this:

  1. I am able to print using xprinter test tool.
  2. I installed QZ tray, but im not sure how to validate it.
  3. I created a raw printer profile in sale invoice, what do i need to enter in raw commands?

So i was able to initiate print from erpnext, i took an example of http://labelary.com/viewer.html
and it printed the entire commands as print.
Now i want to print the invoice, how do i do that?

I think you have to select Jinja and not check raw printing (as counterintuitive as that sounds):

And here’s an example of a print format for a POS invoice (from this repository):

<style>
	.print-format table, .print-format tr, 
	.print-format td, .print-format div, .print-format p {
		line-height: 150%;
		vertical-align: middle;
	}
	@media screen {
		.print-format {
			width: 4in;
			padding: 0.25in;
			min-height: 8in;
		}
	}
</style>

{% if letter_head %}
    {{ letter_head }}
{% endif %}

<p class="text-center" style="margin-bottom: 1rem">
	{{ doc.company }}<br>
	<b>{{ doc.select_print_heading or _("Invoice") }}</b><br>
</p>
<p>
	<b>{{ _("Receipt No") }}:</b> {{ doc.name }}<br>
	<b>{{ _("Cashier") }}:</b> {{ doc.owner }}<br>
	<b>{{ _("Customer") }}:</b> {{ doc.customer_name }}<br>
	<b>{{ _("Date") }}:</b> {{ doc.get_formatted("posting_date") }}<br>
	<b>{{ _("Time") }}:</b> {{  doc.get_formatted("posting_time") }}<br>
</p>

<hr>
<table class="table table-condensed">
	<thead>
		<tr>
			<th width="50%">{{ _("Item") }}</th>
			<th width="25%" class="text-right">{{ _("Qty") }}</th>
			<th width="25%" class="text-right">{{ _("Amount") }}</th>
		</tr>
	</thead>
	<tbody>
		{%- for item in doc.items -%}
		<tr>
			<td>
				{{ item.item_code }}
				{%- if item.item_name != item.item_code -%}
					<br>{{ item.item_name }}
				{%- endif -%}
				{%- if item.serial_no -%}
					<br><b>{{ _("SR.No") }}:</b><br>
					{{ item.serial_no | replace("\n", ", ") }}
				{%- endif -%}
			</td>
			<td class="text-right">{{ item.qty }}<br>@ {{ item.get_formatted("rate") }}</td>
			<td class="text-right">{{ item.get_formatted("amount") }}</td>
		</tr>
		{%- endfor -%}
	</tbody>
</table>
<table class="table table-condensed no-border">
	<tbody>
		<tr>
			{% if doc.flags.show_inclusive_tax_in_print %}
				<td class="text-right" style="width: 70%">
					{{ _("Total Excl. Tax") }}
				</td>
				<td class="text-right">
					{{ doc.get_formatted("net_total", doc) }}
				</td>
			{% else %}
				<td class="text-right" style="width: 70%">
					{{ _("Total") }}
				</td>
				<td class="text-right">
					{{ doc.get_formatted("total", doc) }}
				</td>
			{% endif %}
		</tr>
		{%- for row in doc.taxes -%}
		  {%- if not row.included_in_print_rate or doc.flags.show_inclusive_tax_in_print -%}
			<tr>
				<td class="text-right" style="width: 70%">
				    {% if '%' in row.description %}
					    {{ row.description }}
					{% else %}
					    {{ row.description }}@{{ row.rate }}%
					{% endif %}
				</td>
				<td class="text-right">
					{{ row.get_formatted("tax_amount", doc) }}
				</td>
			<tr>
		  {%- endif -%}
		{%- endfor -%}

		{%- if doc.discount_amount -%}
		<tr>
			<td class="text-right" style="width: 75%">
				{{ _("Discount") }}
			</td>
			<td class="text-right">
				{{ doc.get_formatted("discount_amount") }}
			</td>
		</tr>
		{%- endif -%}
		<tr>
			<td class="text-right" style="width: 75%">
				<b>{{ _("Grand Total") }}</b>
			</td>
			<td class="text-right">
				{{ doc.get_formatted("grand_total") }}
			</td>
		</tr>
		{%- if doc.rounded_total -%}
		<tr>
			<td class="text-right" style="width: 75%">
				<b>{{ _("Rounded Total") }}</b>
			</td>
			<td class="text-right">
				{{ doc.get_formatted("rounded_total") }}
			</td>
		</tr>
		{%- endif -%}
		{%- for row in doc.payments -%}
			<tr>
				<td class="text-right" style="width: 70%">
				    {{ row.mode_of_payment }}
				</td>
				<td class="text-right">
					{{ row.get_formatted("amount", doc) }}
				</td>
			<tr>
		{%- endfor -%}
		<tr>
			<td class="text-right" style="width: 75%">
				<b>{{ _("Paid Amount") }}</b>
			</td>
			<td class="text-right">
				{{ doc.get_formatted("paid_amount") }}
			</td>
		</tr>
		{%- if doc.change_amount -%}
			<tr>
				<td class="text-right" style="width: 75%">
					<b>{{ _("Change Amount") }}</b>
				</td>
				<td class="text-right">
					{{ doc.get_formatted("change_amount") }}
				</td>
			</tr>
		{%- endif -%}
	</tbody>
</table>
<hr>
<p>{{ doc.terms or "" }}</p>
<p class="text-center">{{ _("Thank you, please visit again.") }}</p>

Thanks, Levi for the amazing response. I saw the repository and our end application looks very similar, with few differences.
So I took the example of print format for sale invoice, and it was able to generate fine preview with all details but once i click on the print button with the linked printer - print profile it throws me an error that
“PDF printing via “Raw Print” is not supported.
Please remove the printer mapping in Printer Settings and try again.”

image

image

my print profile linked with sale invoice:

Hi Eeshan - I’ll have a look later, but I suspect I gave you bad advice the first time. I’m thinking that ticking the “Raw Printing” box and leaving everything else the same might make this work (the repository bypasses ERPNext’s print dialog so it probably doesn’t matter there whether it’s ticked or not).