Freehand drawing GoJS within canvas

I am using freehand drawing feature of GOJS. My canvas size is 312*308. I want the freehand drawing tool to draw within this canvas. Is there anyway to achieve this. That is i dont want vertical or horizontal scroll bars enabled. Just need to draw within canvas.

Does this sample help demonstrate some of what you need?

I have already checked the link you provided. What you suggested will work for nodes. I am working on drawing using sample. Freehand Drawing Tool. Will it be helpful in this sample?

It isn’t clear what you are asking for.

Perhaps you just want to override FreehandDrawingTool.addPoint to limit the input point to points within the viewport.

Yes that is right.
Is it possible to set a point like that. Can you provide some examples. I need to restrict in x =0 to 300 and y=0 to 280 points

Just override FreehandDrawingTool.addPoint to limit the value used from the Diagram.lastInput.documentPoint. You don’t want to ignore mouse events that are outside the bounds that you care about, do you? You just want to pretend that the mouse is at the closest point in the bounds to the actual InputEvent.documentPoint.

Hmmm, maybe you do want to skip input events when the mouse is outside of the desired bounds. I don’t know what you want – you’ll need to decide.