PDFJsAnnotations icon indicating copy to clipboard operation
PDFJsAnnotations copied to clipboard

Change fabricObj's property dynamically during loadFromJSON

Open abhimanusharma opened this issue 3 years ago • 3 comments

I am trying to achieve something like this,

inst.fabricObjects.forEach(function(fabricObj, index) {
    fabricObj.set({
        lockMovementX: true,
        lockMovementY: true,
        lockScalingX: true,
        lockScalingY: true,
    });
});

to stop a user to change the position of iText object or anyother fabric object. In case of item like iText object user should be able to update the text value but not move or scale the object.

I also tried this but now object is still moving.

PDFAnnotate.prototype.loadFromJSON = function(jsonData) {
	var inst = this;
	inst.fabricObjects.forEach(function(fabricObj, index){
		if (jsonData.length > index) {
			fabricObj.loadFromJSON(jsonData[index], function () {
				let fabricObjsJSON = fabricObj.toJSON();
				fabricObjsJSON.objects.map(item => {
					item.lockMovementX = true;
					item.lockMovementY = true;
					item.lockScalingX = true;
					item.lockScalingY = true;
					return item;
				});
				console.log(fabricObjsJSON);

				inst.fabricObjectsData[index] = fabricObj.toJSON();
			})
		}
	});
}

abhimanusharma avatar Apr 14 '21 06:04 abhimanusharma

@RavishaHesh any solution for this?

abhimanusharma avatar May 03 '21 06:05 abhimanusharma

@abhimanusharma if you still need a solution for this let me know

RavishaHesh avatar Aug 28 '21 11:08 RavishaHesh

me, I need a solution for this, THX

jesesqui avatar Mar 09 '22 17:03 jesesqui