human-tools / toolbox-web

Simple Secure and Private Tools for everyday humans
https://humantools.io
22 stars 3 forks source link

[QuickSign] The drawings are not positioned correctly on pdf #91

Open bnchi opened 1 year ago

bnchi commented 1 year ago

Original drawing :

Screen Shot 2022-12-19 at 12 55 07 PM

Signed pdf results :

Screen Shot 2022-12-19 at 12 55 20 PM

mkhatib commented 1 year ago

Damn it. I had to rewrite the positioning logic for paths because we weren't repositioning them correctly after moving them post initial creation. But Fabric doesn't update the actual paths instead it changes a left/top property of them and leave paths as is. I'll continue looking into this now.

mkhatib commented 1 year ago

This is tricky, my brain is fried thinking of this and trying to get it to work. Fabricjs adds top/left on initial creation but doesn't seem to be useful for positioning initially, but on moving they don't update the path instead they update left and right leaving the path as is. I tried normalizing it by just depending on the left/top to position and always starting the path at 0,0 but that doesn't seem to work since left/top refer to the bounding box and not the first point the path was created at.

I am tempted to look at other solutions other than Fabric.

@bnchi do you wanna give it a try at fixing this?

mkhatib commented 1 year ago

The alternative is to drop my latest changes and revert back to getting the initial positioning working and disabling moving paths after creation. This would work but would not allow us to do the saved signatures feature. It'll probably be better than what we have now.

bnchi commented 1 year ago

This is tricky, my brain is fried thinking of this and trying to get it to work. Fabricjs adds top/left on initial creation but doesn't seem to be useful for positioning initially, but on moving they don't update the path instead they update left and right leaving the path as is. I tried normalizing it by just depending on the left/top to position and always starting the path at 0,0 but that doesn't seem to work since left/top refer to the bounding box and not the first point the path was created at.

I am tempted to look at other solutions other than Fabric.

@bnchi do you wanna give it a try at fixing this?

No I don't think i'm gonna spend time fixing it tbh, let's try this https://github.com/steveruizok/perfect-freehand what do you think ? @mkhatib

bnchi commented 1 year ago

I also did some research, maybe http://dmitrybaranovskiy.github.io/raphael/reference.html#Paper.text sounds like a pretty good option and good API docs. It uses svgs

mkhatib commented 1 year ago

If that's something you'd like to try let me know. Otherwise, I'll take a look soon.

Kinda playing around with building my own annotator - mostly to learn and see if I can build something usable. If you're interested in that let me know I can push the code I have to a private repo (code is still a mess and at the beginning).

bnchi commented 1 year ago

If that's something you'd like to try let me know. Otherwise, I'll take a look soon.

Kinda playing around with building my own annotator - mostly to learn and see if I can build something usable. If you're interested in that let me know I can push the code I have to a private repo (code is still a mess and at the beginning).

I'll try to make the sign tool work with the options I gave. I think building an annotator from scratch would be a-lot of fun I'll check it out when you decide to open source it :)