I created custom doctype called Label Printer and i made two Label Printers: 1.Citizen and 2. Zebra.
In print_layout.html, how can we add Label Printer doc options(1.Citizen and 2. Zebra) and is possible to get items details of any doc(Purchase Invoice/Purchase Receipt) when selection of Citizen/Zebra printer?
Right now I added manually in print_layout.html file. Please find in attached one.
Any suggestions?
it is quite difficult i think but i suggest you to add select field and custom button on your Purchase invoice and purchase reciept and then on the basis of selection field you add render your custom template in pdf format
Sorry for the late response @max_morais_dmm
Right now we are implementing through custom script for selecting Printer options and making .PRN file for Purchase Invoice Items.
frappe.ui.form.on(“Purchase Invoice”, “refresh”, function(frm, cdt, cdn) {
frm.add_custom_button(__(“Make Label”), function() {
var label_flag = false;
var d = new frappe.ui.Dialog({
title: __(“Select The Printer!”),
‘fields’: [{
“fieldname”: “label_printer”,
“fieldtype”: “Link”,
“options”: “Label Printer”,
“reqd”: 1,
“onchange”: function(e) {
console.log(" label_flag-----" + label_flag);
if (label_flag == false) {
if (this.value != “Citizen” && this.value != “”) {
label_flag = true;
frappe.throw(“Sorry!! This printer not available!”);
}
} else {
label_flag = false;
}
}
}],
primary_action: function() {
d.hide();
var label = d.get_values();
console.log(" label_printer-----" + label.label_printer);
display_dialog_box_for_ncopies(label.label_printer,cur_frm.doc.name);
}
});
d.show();
}); //end of custom_button…
});
function display_dialog_box_for_ncopies(label,invoice){
var d = new frappe.ui.Dialog({
title: __(“Please Submit how many copies you want!”),
‘fields’: [
{
“fieldname”: “ncopies”,
“fieldtype”: “Data”,
“label”: “Enter Copies”,
“reqd”: 1,
“onchange”: function(e) {
console.log(" ncopies-----" + this.value);
var ncopies = Number(this.value);
if (ncopies % 1 != 0) {
frappe.throw(" The Entered Copies value should be integer!“);
} else if (ncopies < 0) {
frappe.throw(” The Entered Copies value should be positive!“);
} else if (ncopies == 0) {
frappe.throw(” The Entered Copies value should be greater than zero!“);
}
}
}
],
primary_action: function(){
d.hide();
var label_input = d.get_values();
console.log(” ncopies-----“+label_input.ncopies);
console.log(” label-----“+label);
console.log(” invoice-----"+invoice);
make_prn_file(label_input.ncopies,invoice,label);
}
});
d.show();
}
function make_prn_file(ncopies,invoice,label){//to make prn file in server side…
frappe.call({
method: “nhance.api.make_prnfile”,
args: {
“invoice”: invoice,
“ncopies”: ncopies,
“label”: label
},
async: false,
callback: function(r) {}
});
}
Dear All,
I have set up a reasonably simple label printing facility using self-hosted JsBarcode, as in:
su - ${INSTANCE}
JSBARCODE_VERSION=[3.11.0]
cd ~/frappe-bench/sites/assets/js
wget https://cdn.jsdelivr.net/npm/jsbarcode@${JSBARCODE_VERSION}/dist/JsBarcode.all.min.js
I have created customised print templates for barcode labels, with serial numbers and the works.
I can print those labels one by one, but not several ones in one go, because wkhtmltopdf does not recognise the JsBarcode output. Any clues?
Also, anyone, who want to get more details on how to set up label creation and printing (and bypassing the A4/Letter paper size limitation hardcoded into ERPNext), please let me know, and I open a separate thread with more details.
Cheers!
Chris
@ragh@Mohammed_Redha the recently added ‘Raw Printing’ Feature might interest you! you can now directly send these commands to a printer instead of saving it to a PRN file. Please use this feature and share your feedback.
@clarsen “JsBarcode.all.min.js” library is included in the Frappe Framework. you can access it via the global object ‘JsBarcode’ in javascript. You do not need to import it again. Also, ‘JsBarcode’ would not be available to the ‘wkhtmltopdf’ as it is a JS library. I think your requirement might be solved using ‘Raw Printing’ Feature, depending on what printer you are using.
Thanks a lot, indeed, for the heads-up regarding the existing inclusion of JsBarcode. This greatly simplified my code.
As for the raw printing feature, I am a bit lost. I am using a Bixolon label printer (which uses essentially Zebra drivers). Any hints? Thanks a lot!
Chris