RavishaHesh / PDFJsAnnotations

Wrapper for PDF JS to add annotations
MIT License
333 stars 99 forks source link

Change fabricObj's property dynamically during loadFromJSON #33

Open abhimanusharma opened 3 years ago

abhimanusharma commented 3 years ago

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 commented 3 years ago

@RavishaHesh any solution for this?

RavishaHesh commented 3 years ago

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

jesesqui commented 2 years ago

me, I need a solution for this, THX