How to link custom print format for custom print buttons

i add two print buttons in doctype
i want when click each button the print format for the doctype change for specific print format
image

Please add the window location url and redirect them with your custom logic or first change the value of print format in doctype then your problem is resolved. My suggestion is u can write the redirect custom code in your all button for specific url redirect every time with selected print format

frappe.ui.form.on("Journal Entry", {
	refresh: function (frm) {
		frm.add_custom_button(__("Label Print"), function () {
			const w = window.open(
				frappe.urllib.get_full_url(`/api/method/frappe.utils.print_format?
					doctype=${encodeURIComponent("Journal Entry")}
					&name=${encodeURIComponent(frm.doc.name)}
					&format=${encodeURIComponent("Cheque Row 2")}`)
			);
			if (!w) {
				frappe.msgprint(__("Please enable pop-ups for this site."));
			}
		});
	},
});```
i try this code and does not work

first change the value of print format in doctype then your problem is resolved.
also this does not work with me

def update_print_format(data):
    try:
        doc = frappe.get_doc("Print Format","Cheque Row 2")
        doc.html = data
        doc.save()
        values = {'doctype': doc.name,'name': 'Journal Entry'}
        data = frappe.db.sql(""" UPDATE tabDocType SET default_print_format =%(doctype)s WHERE name = %(name)s;""", values=values, as_dict=0)
        return 0
    except:
        return -1
print(frm, cdt, cdn) {
        let row = frappe.get_doc(cdt, cdn);
        data ='';
        frappe.call({
            method: 'my_app.my_scripts.print.update_print_format',
            args: { data: data }
        }).done((r) => {
            if (r.message[0] == 0) {
                navigateToPrintFormatUI(frm);
            }
        })
 })
function navigateToPrintFormatUI(frm) {
        var docName = frm.doc.name;
        var doctype = 'Journal Entry';
        var printFormatUrl = `/app/print/${encodeURIComponent(doctype)}/${encodeURIComponent(docName)}`;
        window.location.href = frappe.urllib.get_full_url(printFormatUrl);
    }