Fabric js loadFromJSON function Calling issue

On button click it working fine but i want to do with page load I’m getting JSON Data and calling loadFromJSON() function is running but code is not running inside the function’s idn why please help;

I’m rendering frappe page and on page load i just wanted to call PDFAnnotate.prototype.loadFromJSON

is there any other way to do this (write function loadFromJSON)

PDFAnnotate.prototype.loadFromJSON = function (jsonData) {
	var inst = this;

	alert(jsonData)

	$.each(inst.fabricObjects, function (index, fabricObj) {
		if (jsonData.length > index) {
			fabricObj.loadFromJSON(jsonData[index], function () {
				inst.fabricObjectsData[index] = fabricObj.toJSON()
			})
		}
	})
}

frappe.db.get_doc('Docusign', nameParameter)
	.then(doc => { 
		if (doc.annotate_json !== undefined) {
			var pdfred = "http://0.0.0.0/" + doc.attached_document

			var pdf2 = new PDFAnnotate("pdf-container", pdfred, {
				onPageUpdated(page, oldData, newData) {
					console.log(page, oldData, newData);
				},
				ready() {
					console.log("Plugin initialized successfully");
				},
				scale: 1.5,
				pageImageCompression: "MEDIUM",
			});
			var jsonData = JSON.parse(doc.annotate_json)

		}
		pdf2.loadFromJSON(jsonData);
})