Barcode Label Printing

Need to make a custom print format to print barcode labels from purchase receipt/Material receipt document.
Example: Purchase receipt have 10 item and each item is 1 quantity. then the print format printable areas should loop and make 10 labels with each item row detail.

I am able to pull the item row data in one printable area only. Would like someone to help me understand the page break and loop function in jinja.


refer this Template Designer Documentation — Jinja Documentation (2.10.x)

Yes dear, Reading that only right now.


I was able to achieve the page break for loop next I want to know how to multiple the print quantity.
item A - 1 Qty
Item B - 2 Qty
Item C - 5 Qty

So loop should display ItemA 1 time, Item B 2 Times and Item C 5 times.
Any idea?

I have written custom script to get the above function.
It works in erpnext print button and displays the

{%- for row in doc.items -%}
{%- for qty in range(row.qty) -%}
{{ row. item_code }}

{{row.item_name }}

{{ row.get_formatted(“amount”) }}

{%- endfor -%}
{%- endfor -%}

The print shows {{body}}

it happens as I have put 2 For statement to make loop.

Anyone have any idea on this?

Finally got it working.
Below labels are printed from erpnext purchase receipt document.

Below is sales invoice with its number in barcode format.
This is also done in pos invoice. Barcode at the end of the receipt.


Are these printed as images or sent to the printer as barcode?

Reply from @fkardame

The barcode are sent directly to the printer using print format and not as image.

Using jinja(for pulling items and quantity in row) html(for text and alignments), js(for barcode using SVG) and css (for print media size - can decide the barcode label size ) we are using 1.5inch width *1inch
Created a “barcode label” print format in purchase receipt and material receipt.
So after submission they can just print and select barcode label and print the barcodes in zebra printer from the browser. But not too forget to remove the margin as default and replace is by none and also disable header and footer from print setting in the browser or else it will print the url also.
Hope this will help users in retail business.


Hi @fkardame

Trust you’re doing great. Could you possibly share sample scripts for both the Custom Script and Print Format used in achieving the output shown from the Purchase Receipt document?

This would be extremely helpful in our case