How to print barcode label

Thank you @fkardame
I mean how to set the value of the barcode field?
In other words: if the field type is barcode (I mean by type is the type of the field which might be Int, Float, Text, Table, HTML, barcode, … etc), so how to set the value of this barcode field.

I need to set the value from javascript or from python, and not from user interface. I know that I can enter it directly from the keyboard, but I need to set the value from js or py.
Regards
Bilal

1 Like

Hello @fkardame
As example:

frm.set_value('discount_amount', 100);

Is used to set the value of the field name discount_amount to 0, but if we use the same code to set the value of the barcode field then it will not work. So how can we set the value of the barcode field using javascript and python?

I need to set the value of the barcode to be 1122334455, how?

Regards
Bilal

1 Like

Any help?

1 Like

Hello @JoEz
Can you please help in this if possible?
Because you suggested to use barcode field type, so I expect that you have experience in this (if you can help please).
If not possible, I hope to advise me that it is not possible and then we can find another way.
But normally, it should be possible to set the value of any field !
Regards
Bilal

Try using Value field as {{ doc.barcode }} and field type as Data

<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="{{ doc.barcode}}"/></svg></br> <script src="https://cdn.jsdelivr.net/npm/jsbarcode@3.9.0/dist/JsBarcode.all.min.js"></script>

This is the script we use in print format for barcode

4 Likes

Thank you @fkardame

<script src="https://cdn.jsdelivr.net/npm/jsbarcode@3.9.0/dist/JsBarcode.all.min.js"></script>

Can you please help, if I need to download JsBarcode.all.min.js and place it locally, for example if I placed it under the custom application of the following path:
home/frappe/frappe/apps/collection/collection/public/js/JsBarcode.all.min.js so how it will be the link to be used for src?

Anyway, this is for printing and thank you @fkardame

But have you tried to use the barcode field type which is existed in erpnext?
I hope that @JoEz or @pratu16x7 can help in advising how to set the value field of the barcode field because they are the owner andn contributor for this field type from this topic:

Regards
Bilal

1 Like

Have a look at:

1 Like

Hello @JoEz
What you mentioned is about the options and not about the value.
I am asking how to set the value of the barcode from javascript and not the options.

In other words:
If I have a data field that has the following value: “11223344” and I need to set the value of the barcode field to this data field from javascript, what is the js code to be used?

Is it frm.set_value('barcode_field_name', data_field_name); ?
I tried set_value and it did not work.

Please advice.
Regards
Bilal

1 Like

Could you please share your script, or info on how to add additional button and wire up script to it.

1 Like

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