How to print barcode label

We did not add any new button.
We jusy created a new primt. Format of the documents and that print format have all thr page size and print design

1 Like

Hi @fkardame, I have been trying to print expiry date in V11, but the variable is not giving me any data, am I doing something wrong? how did you set it up?

1 Like

Check if the batch field is named as ‘batch’ or ‘batch_no’

1 Like

Is there any possible help that i can get with the labels?
I need as design

Item code
Barcode
Item price

I have knowledge on custom print format for sales order, invoice, pos invoice
But no clue how to proceed with custom print format for labels ( i have a zebra desktop printer also ) for this purpose ,
Any help on this topic is appreciated , like from where to start

1 Like

If you do a google search for ZPL Manual you should turn up several links to the Zebra Print Language user manual. Is it downloadable in PDF format and contains complete information on how to setup a label format using simple examples.

If you prefer to do it visually, you can go to the Zebra website and search for the free downloadable version of their Zebra Designer software. It is a drag-and-drop visual editor to make label layouts. You can test your layout by printing it directly to the Zebra printer. If it turns out the way you want then you print to file the same label and it will give you the ZPL code in the file you need to place in your print format.

Getting the manual and learning the language is the best bet, but there is an alternative if you are not good with code.

Also have a look at this thread for more details and examples:

BKM

1 Like

Thanks for your reply BKM, you remember the thread i post before , i tried what you told me just as for testing , and i checked the option print to file and i got the code of the label i still need to add the texts as mentioned in the post above, though that’s not the problem for me atm , i don’t have knowledge in print format on how to integrate this print to file code and link it to my database to fetch ( item code, item price and barcode number ) this is my recent problem , like i tested the code mentioned with your thread that you linked but whenever i press print zpl i get the code from purchase receipt and not the barcode , i was just testing, i think differences in field is the issue because i just want a demo , but this thread is not working for me due to being able to see the code when pressing on print zpl , and i don’t see a label

1 Like

Zebra has browserprint.js so you can do raw printing directly with ease. You just need install it then include browserprint.js api in your app then you’re ready to go

1 Like

I use a small program ZPL Designer, https://zpldesigner.com/ , to preview the label using the code generated. Just copy the code after you press print zpl and paste it into the program and click on Preview. I used the program for designing the label first and then transferring the design back to ERPNext.

2 Likes

thank you @petereb for your reply, i tested the code that you shared , but when pressing print zpl, i just see code , i don’t see the preview of the label , the problem is now i need help with custom format as i said on top i just tried to copy your custom format , but it said to me check error logs or contact tech support though i have knowledge with custom formats Llike SINV, POS as i mentioned on top, i just want it to test and check where i can change as i wanted it doc.name or related fields. but i get this error log.

1 Like

Please go through this post and check if you can understand it…
This does not required any app to be used. It is just a Print format script used as per the size of the barcode paper.
and sent to the printer using the browser print method.
Let me know if you need any help.

1 Like

Have created a new print format with Print format type as “Jinja”.
used your below suggested script

Getting only empty print with the new format.
Am I missing something.
Your help here is appreciated

1 Like

also add below at the bottom -

<script src="http://localhost:8000/assets/frappe/js/lib/JsBarcode.all.min.js"></script>
<script>
JsBarcode(".barcode").init();
</script>
2 Likes

You can also refer my reply in the other post. There i have explained the detailed steps and code for the same.

1 Like

can u pls share the script…

HTML

<style id=label>
	.print-format table, .print-format tr, 
	.print-format td, .print-format div, .print-format p {
		font-family: arial;
		line-height: 100%;
		vertical-align: middle;
		white-space: nowrap;
		overflow: hidden;
		width: 100%;
	}
	@media screen {
		.print-format {
			width: 1.5in;  <!--This is a width of the barcode label, change according to your use -->
			padding: 0.1in;
			min-height: 1in; <!--This is a height of the barcode label, change according to your use -->
			 
		}
	}
</style>

{%- for row in doc.items -%}
{% set abbr = frappe.db.get_value('Company', doc.company, 'abbr') %}
{% set tax_name = 'VAT - {}'.format(abbr) %} <!--This is a TAX Definition, change according to your use -->
{% set taxes = frappe.get_all('Item Tax', filters={'parent': row.item_code, 'tax_type': tax_name}, fields=['tax_rate']) %} <!--This is a width of V11, change according to your version -->

		{%- for qty in range (frappe.utils.cint(row.qty)) -%}
<p class="text-center" style="font-size:9px">
<b class="text-center" style="font-size:10px"> COMPANY NAME HERE</b> </br>
<b style="font-size:9px" >Item Code: {{row.item_code }} </b></br>
			<svg class="barcode"
				jsbarcode-margin="0"
				jsbarcode-margintop="0"
				jsbarcode-marginbottom="1"
				jsbarcode-height="25"
				jsbarcode-width="1"
				jsbarcode-fontsize="12"
				jsbarcode-flat="true"
				jsbarcode-value="{{  row.batch or row.item_code}}"/></br>

<b style="font-size:12px">{{ frappe.utils.formatdate(row.expiry_date, "MM/yy")or "" }}  &nbsp; &nbsp; 
   BD. {{ '%0.3f'|format (frappe.db.get_value("Item Price", {"item_code": row.item_code, "price_list": "Standard Selling"}, "price_list_rate" ) +(frappe.db.get_value("Item Price", {"item_code": row.item_code, "price_list": "Standard Selling"}, "price_list_rate" ) * (taxes[0]['tax_rate']))/100|float) }}  </b><br><small style="font-size:8px"> {% if (((taxes[0]['tax_rate']))|float) ==5%}
<b> Incl. VAT {% else %} <b></b>{% endif %}</small></br><b style="font-size:8px"> {{row.item_name }}  </b></p>
<p class=footer> </p> 
{%- endfor -%}
{%- endfor -%}
<script src="https://cdn.jsdelivr.net/npm/jsbarcode@3.9.0/dist/JsBarcode.all.min.js"></script>
<script>
JsBarcode(".barcode").init();
</script>

CSS

@media print {
  footer {page-break-after: always;}
}

Some fields will have to be changed depending on the version you’re using V-11 or V-12

2 Likes

hi @fkardame

I saw your great posts and how you achieve superb results in multiple barcodes printing. Unfortunately, I have v14, and still having problems despite spending weeks in trying to figure out…

May I know the HTML/CSS, which doctype is it? Purchase receipt, Material receipt or item master?

1 Like

We have it working on v13 but it does not work with the existing js for barcode generation, instead we used a new method to convert barcode in an image and then use it for printing.

You can use any doctype and change the fields.

Does that mean that optic_store/label_tag_small.html at master · f-9t9it/optic_store · GitHub also doesn’t work in v14?

that app is not for v13 or v14

barcode may not work.

1 Like

thank you for updating this info! :slight_smile: