Barcode Printing on ERPNext

We use GitHub - metafloor/bwip-js: Barcode Writer in Pure JavaScript - and host on our server. We use it to generate variable barcodes. You can use their public api. The advantage is that in print format you will pass a variable (custom html field; bcid is barcode type and variable portion to be modified is text=… in our case it is a variable URL) and then the api returns image - which works well with erpnext… you can test api as follows. Change bcid=code128 (?) and text= per example above…

I am interested to know if / how you are structuring the barcode so that it can be imported in to ERPNext POS?

1 Like

Then you must be having a firewall which is not allowed the jscodes to be fetched.

as said by @zerodiscount host the js codes on local server and point it to the local file in the print format.

Yes we host it on offline pos too so we an print the offline_pos_name on the receipt

1 Like

@fkardame - seems you have expertise in implementing ERPNext POS in retail. Is it possible to use a QR code type barcode that contains a URL (ERPNext API call) to post item and qty directly into POS at checkout? So this would allow customers to print a QR barcode sticker say at the vegetable aisle (QRCode would encode url to add item, qty and price?) - and then at checkout when scanned - it would enter into the POS cart - the item, qty and possibly price using the URL???

Any suggestions on how to implement item/ qty barcode for POS without storing that info in a doctype for each barcode ticket printed?

@avaiskhatri - you may have a CORS type issue - look into it…

Never worked on that, sounds like a good idea and also do-able but no idea how long it will take to customize and how much it will cost.

It all depends on how much the final user is ready to contribute and how much work it will reduce for the final end users.

You may need to add a “host_name” entry to site config. Like:

"host_name": "http://192.168.20.201"

It resolves image and pdf problems.

Adding host_name as “http://erp.example.com” did not worked. Same results. Print with empty spaces is coming.

Just click on Full page button and checked console.log it showing

jQuery is not defined

Which impliese frappe is not loading js libraries for print, on inspecting code there are not JS files being called.

Anyone who have used JS for print formats ??

@avaiskhatri have you got any solution. I am also facing same problem

having same problem… any solutions guys…

What problem

only product name comes…barcode missing

Then you have barcode generating js missing or not internet connection for the same.

how i check that bro and if yes then where shall i download from n how to update it…

You need to debug it on your own, I will not be able to help with everything sorry.

Good Luck.

Hello @avapiitahari please could you please share the steps to make this ?

I facing the same problem in v14. Could it be its not working for print format in doctype item or it has nothing to do with doctype type?
Is your version v14?
I have the jsbarcode both pointed to local or direct link, still not working, only bar code shows in full page print view, but doesn’t show in pdf, nor print view.

nobody is informing about the issue they’re facing while just saying that it does not work.

If someone can be more specific then I can help.

Hi @fkardame

I just want to say I’m very thankful for you being there.

I am no expert as I don’t have a background coding.

But I figured out some things, in v14 at least.

Différent things but might not be related.

  1. When the HTML gets converted to pdf, erpnext is using gkhtmltopdf. The problem is gkhtmltopdf works with JavaScript but not with js from what I read. It use very basic JavaScript, so depending on the JavaScript version, it will fails to execute the code because most likely of syntax error or elements that aren’t present with the compatibility version of JavaScript inside gkhtmltopdf. The thing is I don’t know which version of JavaScript gkhtmltopdf uses and if there is a way to change gkhtmltopdf for another HTML to pdf, and replacing it in erpnext.

  2. Some CSS code will not be compatible with gkhtmltopdf. Making it not displaying the barcode… (not sure why)

So I think, we either need to use basic JavaScript coding in the HTML print format (jinja? Js?) to fit the compatibility of the JavaScript version of gkhtmltopdf. Either we replace gkhtmltopdf with something equivalent.

Since I don’t have programming skills, it takes me weeks to just figure out some simple codes.

I see erpnext still includes jsbarcode.js in their install, but what is the use of it if we can’t use it in pdf?

In summary :

1- the print view and choosing print format. Everything words but just no barcode. By everything I mean all HTML and css code for other non related barcode fields such as item name, item code etc…

2- the full page view button in print view option has everything working. Barcode displays and all is working.

3- the pdf generated has 2 things not working : 1- some css working 2- no barcode displayed.

The good thing is I can still print with option 2, however, I have like 500 items and more, I can’t print 1 label per page, and also to click on every single item to print 1 by 1 is not efficient. And I don’t know how I can print the selection of some items or all items.

The item list page where I CAn select can only generate pdf but no option for full page. So that is even worse, as the pdf can’t even view display and also has css not loading up.

I saw in ur other posts, that u also can’t get it to work. So I am not sure, should we give up? What is your alternative solution?

I dont use pdf button to print barcodes as pdf will resize the paper to a4 by default.

I will share the barcode code I used in v13 rest is the same from before.

src='https://barcode.tec-it.com/barcode.ashx?data={{row.batch or row.item_code}}&code=Code128&multiplebarcodes=false&translate-esc=true&unit=Fit&dpi=96&imagetype=Gif&rotation=0&color=%23000000&bgcolor=%23ffffff&codepage=Default&qunit=Mm&quiet=0' 
style="height:35px; padding:1px;"?draggable="false"/><br>

You can use it and check if that works. I have no answer for other issue your facing with gkhtml2pdf as I have never used it yet.

Good Luck.

1 Like