Replies: 1 comment
-
Update I tried option 2 and its seems viewOverlayBuilder doesn't get impact by any gestured i.e. if I zoom into the pdf and scroll around the drawings are fixed relative to the screen (i.e. if its in the middle of screen, it stays in the middle of the screen even if i pan the pdf). Thats not the case when using |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey! Im looking into options for allowing users to draw on top of a pdf. It feels like there are quite a few options for this (as well as quite a few interesting challenges). The goal of this discussion is to see if anyone has any experience with this/what approach you would recommend.
The options I am currently considering are:
pagePaintCallbacks
Add a viewOverlayBuilder which just contains a GestureDetector. This can handle creating some points from user dragging on the viewer and update the state. Then using
pagePaintCallbacks
we can paint these paths onto the canvas.The part Im struggling with in this approach is getting the
GestureDetector
into canvas coordinates but Im guessing that should be relatively simple?The other thing that worries me about this approach is we have to update the state on every additional point/path the user draws. It feels like in an ideal world we would just add extra points as they come in.
Just showing a whole drawing thing into viewOverlayBuilder
Another option Im considering (although haven't tried yet) is showing a drawing thing into the overlay separately. The advantage being I don't have to worry about converting between coordinates and also the state update for the drawing can be handled independently of the
pagePaintCallbacks
which I think can only be called on initial render (although that could be completely wrong?). In my head something scares me about having 2 canvases stacked on top of each other but Im assuming this would work as the scaling/rotating etc is handled by the parent interactive viewer? I kinda feel like it would make more sense if we could just access the canvas of the pdf directly and draw on that but I can't find a way to do that?If anyone has any better ideas/thoughts on these options/code I can steal it would be much appreciated!
Beta Was this translation helpful? Give feedback.
All reactions